relatedSpace.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <div id="relatedSpace">
  3. <div class="condition">
  4. <div class="header">
  5. <el-button style="float:left;" size="small" type="default" icon="el-icon-back" @click="goBack"></el-button>
  6. <div class="edit-tool" v-if="!(cenoteObj.onlyRead == 'true')">
  7. <el-button v-if="isMyTab == 2" size="small" style="float:right" @click="dialogVisible = true">添加</el-button>
  8. <div v-else>
  9. <el-button v-show="!isEdit" @click="changeEditType" size="small" style="float:right">编辑</el-button>
  10. <el-button v-show="isEdit" size="small" @click="saveEdit" style="float:right">保存</el-button>
  11. <el-button v-show="isEdit" size="small" @click="cancelEdit" style="float:right">取消</el-button>
  12. </div>
  13. <addSpaceDialog :dialogVisible.sync="dialogVisible" ref="addSpaceDialog" @refresh="refresh"
  14. :params="cenoteObj" :spaceType="spaceType"
  15. :floorType="floorType"></addSpaceDialog>
  16. </div>
  17. <el-badge :is-dot="showSpaceDot" style="margin-left:15px;">
  18. <label style="line-height:32px;">业务空间类型:</label>
  19. <el-cascader v-model="space" placeholder="请选择业务空间" :props="{value:'code',label:'name',children:'zoneType'}"
  20. :options="spaceList"
  21. @change="changeSpace" style="margin-left:15px;"></el-cascader>
  22. </el-badge>
  23. </div>
  24. <div class="saga-build-tab">
  25. <el-radio-group v-model="isMyTab" @change="changeRadio" style="width: 136px;">
  26. <el-radio-button label="1">平面图</el-radio-button>
  27. <el-radio-button label="2" class="space-own-radio" style="width: 68px;">列表</el-radio-button>
  28. </el-radio-group>
  29. </div>
  30. <div v-show="isMyTab == 1" class="data-item">
  31. <el-badge :is-dot="showBuildDot">
  32. <label style="line-height:32px;padding: 0 10px;">所属建筑:</label>
  33. <el-select v-model="building" placeholder="请选择建筑" @change="changeBuilding" v-loading="buildingLoading">
  34. <el-option v-for="item in buildingList" :key="item.value"
  35. :label="item.localName || item.name"
  36. :value="item.id"></el-option>
  37. </el-select>
  38. </el-badge>
  39. <el-switch v-if="!(cenoteObj.onlyRead == 'true')" style="margin-left:15px;" v-model="isAI" @change="handleChangeAI"
  40. active-text="打开AI">
  41. </el-switch>
  42. <div style="height:calc(100% - 42px);margin:10px 0 0 0;width:100%;">
  43. <el-row
  44. style="height:100%;margin:0;width:55%;position:relative;display:inline-block;border:1px solid #e4e4e4;">
  45. <el-col :span="4" style="height:100%;border-right:1px solid #e4e4e4;">
  46. <el-scrollbar style="height:100%;">
  47. <div class="floor" style="height:100%;text-align:center;">
  48. <span class="floor-item" style="border-bottom:1px solid #e4e4e4;">楼 层</span>
  49. <div v-if="building" v-loading="buildingLoading">
  50. <span class="floor-item" @click="changeFloor(item)"
  51. :class="{floorItemChoose:(item.id == floor)}"
  52. v-for="item in buildingObj.floor" :key="item.id">{{ item.localName }}</span>
  53. </div>
  54. </div>
  55. </el-scrollbar>
  56. </el-col>
  57. <el-col :span="20" style="height:100%;position:relative;">
  58. <cenote-graphy ref="cenotegraphy" :buildFloorName="buildFloorName"></cenote-graphy>
  59. </el-col>
  60. </el-row>
  61. <div class="elevation-box">
  62. <elevation-map ref="elevationMap" :onlyRead="cenoteObj.onlyRead=='true'" :isEdit="isEdit" :isAI="isAI"
  63. @elevationChecked="handleCheckedSpace"
  64. @elevationUncheck="handleUncheckSpace"
  65. :params="{buildingId: building, objectType: ObjectType, shaftId: $route.query.ShaftId}">
  66. </elevation-map>
  67. </div>
  68. </div>
  69. </div>
  70. <div v-show="isMyTab == 2" class="data-item">
  71. <related-spaceList :space="ObjectType" :buildingList="buildingList" :spaceType="spaceType"
  72. :floorType="floorType" ref="relatedSpacelist">
  73. </related-spaceList>
  74. </div>
  75. </div>
  76. </div>
  77. </template>
  78. <script>
  79. import spaceSelect from "@/components/ledger/lib/spaceSelect";
  80. import relatedSpaceList from "@/components/ledger/cenote/relatedSpaceList";
  81. import elevationMap from "@/components/ledger/cenote/elevationMap";
  82. import addSpaceDialog from '@/components/ledger/cenote/dialog/addSpaceDialog';
  83. import {
  84. queryAllZoneType,
  85. shaftSpaceTypeQuery,
  86. shaftSpaceBuildingQuery,
  87. verticalSpace
  88. } from '@/api/scan/request';
  89. import cenoteGraphy from '@/components/ledger/lib/cenoteGraphy'
  90. import { mapGetters } from 'vuex'
  91. import { buildingQuery } from '@/api/object/build';
  92. export default {
  93. data() {
  94. return {
  95. isMyTab: 1,//默认平面图
  96. isEdit: false,//是否正在编辑
  97. building: '',//当前建筑id
  98. buildingObj: {},//当前建筑obj
  99. buildingList: [],
  100. space: [],//当前业务空间
  101. ObjectType: '',//业务空间code
  102. spaceList: [],//空间list
  103. floor: '',//当前楼层
  104. dialogVisible: false,//添加空间弹窗
  105. spaceType: {},//空间种类
  106. floorType: {},//子组件楼层信息
  107. buildingLoading: false,//左侧列表加载
  108. // showSpaceDot: false,//空间提示红点
  109. // showBuildDot: false,//楼层提示红点
  110. isAI: true,//是否打开AI
  111. buildFloorName: '', //建筑楼层名称
  112. }
  113. },
  114. computed: {
  115. cenoteObj() {
  116. return this.$route.query;
  117. },
  118. showSpaceDot() {
  119. return this.spaceList.length > 1 && this.cenoteObj.onlyRead == 'true' ? true : false;
  120. },
  121. showBuildDot() {
  122. return this.buildingList.length > 1 && this.cenoteObj.onlyRead == 'true' ? true : false;
  123. },
  124. ...mapGetters("layout", ["projectId"])
  125. },
  126. props: {},
  127. components: {
  128. spaceSelect,
  129. relatedSpaceList,
  130. addSpaceDialog,
  131. cenoteGraphy,
  132. elevationMap
  133. },
  134. created() {
  135. this.isAI = this.$route.query.onlyRead == 'true' ? false : true;
  136. this.getSpaceData();
  137. },
  138. methods: {
  139. //获取空间信息
  140. getSpaceData() {
  141. if (this.cenoteObj.onlyRead == 'true') {
  142. let pa = {
  143. shaftId: this.$route.query.ShaftId
  144. }
  145. shaftSpaceTypeQuery(pa, res => {
  146. this.spaceList = res.content.map(item => {
  147. return { code: item.objectType, name: item.objectTypeName };
  148. });
  149. this.showDefaultSpace();
  150. });
  151. } else {
  152. let params1 = {},
  153. //Cascade: [{ Name: 'zoneType', Filters: `ProjectId='${this.projectId}'` }]
  154. params2 = {shaftId: this.$route.query.ShaftId};
  155. let promise1 = new Promise((resolve, reject) => {
  156. queryAllZoneType(params1, res => {
  157. resolve(res)
  158. })
  159. })
  160. let promise2 = new Promise((resolve, reject) => {
  161. shaftSpaceTypeQuery(params2, res => {
  162. resolve(res)
  163. })
  164. })
  165. Promise.all([promise1, promise2]).then(values => {
  166. let val1 = values[0], val2 = values[1]
  167. this.spaceList = val1.content.map(t => {
  168. if (t.name != "元空间") {
  169. this.spaceType[t.code] = t.name;
  170. }
  171. return t;
  172. });
  173. if (val2.content.length) {
  174. this.space = [val2.content[0].objectType];
  175. } else {
  176. this.space = this.spaceList.find((item) => {
  177. return item.code == "GeneralZone"
  178. }) ? ["GeneralZone"] : [this.spaceList[0].code];
  179. }
  180. this.ObjectType = this.space[0];
  181. //加载楼层信息
  182. this.loadBuildingData();
  183. })
  184. }
  185. },
  186. //默认显示默认分区,无默认分区显示第一个分区
  187. showDefaultSpace() {
  188. if (this.spaceList.length && this.cenoteObj.onlyRead == 'true') {
  189. this.space = this.spaceList.find((item) => {
  190. return item.code == "GeneralZone"
  191. }) ? ["GeneralZone"] : [this.spaceList[0].code];
  192. this.ObjectType = this.space[0];
  193. }
  194. //处理空间类型
  195. this.spaceList.map(item => {
  196. if (item.name != "元空间") {
  197. this.spaceType[item.code] = item.name;
  198. }
  199. });
  200. //加载楼层信息
  201. this.loadBuildingData();
  202. },
  203. //获取楼层信息
  204. loadBuildingData() {
  205. if (this.cenoteObj.onlyRead == 'true') {
  206. if (this.ObjectType) {
  207. let param = {
  208. shaftId: this.$route.query.ShaftId,
  209. objectType: this.ObjectType
  210. };
  211. this.buildingLoading = true;
  212. shaftSpaceBuildingQuery(param, res => {
  213. this.buildingLoading = false;
  214. this.buildingList = res.content;
  215. this.handleBuildingData();
  216. });
  217. }
  218. } else {
  219. let param = {
  220. cascade: [
  221. {
  222. name: "floor",
  223. orders: "floorSequenceID desc, name asc",
  224. }
  225. ]
  226. };
  227. buildingQuery(param, res => {
  228. this.buildingList = res.content;
  229. this.handleBuildingData();
  230. });
  231. }
  232. },
  233. //处理建筑楼层数据
  234. handleBuildingData() {
  235. if (this.isMyTab == 2) {
  236. this.$refs.relatedSpacelist.setFloorData(this.buildingList);
  237. }
  238. if (this.buildingList.length) {
  239. this.changeBuilding(this.buildingList[0].id);
  240. } else {
  241. this.buildingList = [];
  242. this.building = '';
  243. this.floor = '';
  244. }
  245. this.buildingList.map(item => {
  246. if (item.id && item.localName) {
  247. this.floorType[item.id] = item.localName;
  248. if (item.floor instanceof Array) {
  249. item.floor.map(f => {
  250. if (f.id && f.localName) {
  251. this.floorType[f.id] = f.localName;
  252. }
  253. })
  254. }
  255. }
  256. });
  257. },
  258. //计算 和当前竖井有关联的空间的垂直交通关系
  259. calculateRelation() {
  260. if (this.isAI && this.building && this.ObjectType && this.cenoteObj.ShaftId) {
  261. let params = {
  262. buildingId: this.building,
  263. objectType: this.ObjectType,
  264. shaftId: this.cenoteObj.ShaftId,
  265. }
  266. verticalSpace(params, res => {
  267. console.log(res)
  268. })
  269. }
  270. },
  271. //改变AI开关
  272. handleChangeAI(val) {
  273. this.calculateRelation();
  274. },
  275. //更改业务空间类型
  276. changeSpace(val) {
  277. this.ObjectType = val[val.length - 1];
  278. this.floor = '';
  279. this.buildingList = [];
  280. this.building = '';
  281. this.changeFloor({ id: '' });
  282. this.loadBuildingData();
  283. this.calculateRelation();
  284. },
  285. //更换建筑
  286. changeBuilding(bid) {
  287. this.buildingObj = {};
  288. this.building = bid;
  289. this.buildingList.map(item => {
  290. if (item.id == bid) {
  291. this.buildingObj = item;
  292. if (item.floor && item.floor.length) {
  293. this.changeFloor(item.floor[0]);
  294. }
  295. }
  296. })
  297. this.calculateRelation();
  298. },
  299. //更换楼层
  300. changeFloor(floorObj) {
  301. this.buildFloorName = `${this.buildingObj.localName || this.buildingObj.name || ""}-${floorObj.localName || floorObj.name || ""}`
  302. this.floor = floorObj.id;
  303. let buildfloor = [this.building, floorObj.id]
  304. this.$refs.cenotegraphy.getFloorMap(buildfloor, this.ObjectType)
  305. },
  306. //平面图选中空间,立面图对应选中
  307. handleCheckedSpace(RoomID) {
  308. this.$refs.cenotegraphy.canvasChecked(RoomID);
  309. },
  310. //平面图取消选中空间,立面图对应取消选中
  311. handleUncheckSpace(RoomID) {
  312. this.$refs.cenotegraphy.canvasUncheck(RoomID);
  313. },
  314. // 编辑
  315. changeEditType() {
  316. this.isEdit = true;
  317. this.$refs.cenotegraphy.edit();
  318. },
  319. //取消编辑
  320. cancelEdit() {
  321. this.isEdit = false;
  322. this.$refs.cenotegraphy.cancelEdit();
  323. },
  324. //保存编辑
  325. saveEdit() {
  326. this.isEdit = false;
  327. this.$refs.cenotegraphy.saveEdit();
  328. // 走保存接口,然后回调渲染
  329. this.$refs.elevationMap.savaEdit();
  330. },
  331. //更换列表或平面图
  332. changeRadio(val) {
  333. if (val == 2) {
  334. this.spaceList.unshift({ code: '', name: '全部' });
  335. }
  336. if (val == 1) {
  337. if (this.spaceList.length > 0) {
  338. this.spaceList.shift();
  339. }
  340. }
  341. if (this.spaceList.length) {
  342. this.changeSpace([this.spaceList[0].code]);
  343. this.space = [this.spaceList[0].code]
  344. }
  345. this.isMyTab = val;
  346. },
  347. //返回
  348. goBack() {
  349. this.$router.push({
  350. name: 'cenotelist'
  351. })
  352. },
  353. //更新
  354. refresh() {
  355. this.$refs.relatedSpacelist.getSpaceList();
  356. this.dialogVisible = false;
  357. }
  358. },
  359. watch: {
  360. isEdit: {
  361. handler(val) {
  362. // this.$refs.cenotegraphy.setSelectAble(val);
  363. }
  364. },
  365. projectId: {
  366. handler(val) {
  367. this.goBack();
  368. }
  369. }
  370. }
  371. }
  372. </script>
  373. <style lang="less" scoped>
  374. .condition {
  375. position: relative;
  376. padding: 10px;
  377. display: flex;
  378. height: calc(100% - 22px);
  379. flex-direction: column;
  380. border: 1px solid #dfe6ec;
  381. background: #fff;
  382. .header {
  383. padding-bottom: 10px;
  384. border-bottom: 1px solid #e4e4e4;
  385. span {
  386. line-height: 33px;
  387. margin-left: 15px;
  388. }
  389. /deep/ .buildFloor {
  390. line-height: 32px;
  391. }
  392. }
  393. .spaceTypes {
  394. .types {
  395. float: left;
  396. width: calc(100% - 200px);
  397. /deep/ .el-tabs__item.is-top {
  398. border-top: 2px solid transparent;
  399. &.is-active {
  400. border-top: 2px solid #409eff;
  401. }
  402. }
  403. }
  404. .deleBtn {
  405. float: left;
  406. width: 200px;
  407. text-align: right;
  408. height: 40px;
  409. border-bottom: 1px solid #e4e7ed;
  410. }
  411. }
  412. }
  413. .saga-build-tab {
  414. position: absolute;
  415. left: 50%;
  416. transform: translateX(-50%);
  417. .tab-main {
  418. float: left;
  419. width: 120px;
  420. padding: 0 5px;
  421. margin: 5px 0;
  422. border: 1px solid #ccc;
  423. background-color: #fff;
  424. height: 30px;
  425. box-sizing: border-box;
  426. text-align: center;
  427. cursor: pointer;
  428. overflow: hidden;
  429. i {
  430. font-size: 18px;
  431. padding-right: 10px;
  432. float: left;
  433. line-height: 30px;
  434. margin-left: 10px;
  435. }
  436. span {
  437. line-height: 30px;
  438. float: left;
  439. }
  440. }
  441. .tab-active {
  442. background-color: #409eff;
  443. color: #fff;
  444. }
  445. }
  446. .data-item {
  447. height: calc(100% - 44px);
  448. padding: 10px 0px;
  449. box-sizing: border-box;
  450. /deep/ .is-horizontal {
  451. display: none;
  452. }
  453. .elevation-box {
  454. height: 100%;
  455. width: calc(45% - 14px);
  456. margin-left: 10px;
  457. display: inline-block;
  458. box-sizing: border-box;
  459. border: 1px solid #e4e4e4;
  460. overflow: auto;
  461. }
  462. }
  463. .floor-item {
  464. padding: 10px 10px;
  465. display: block;
  466. margin: 0px;
  467. cursor: pointer;
  468. }
  469. .floorItemChoose {
  470. background: #e4e4e4;
  471. }
  472. /deep/ .el-scrollbar__wrap {
  473. overflow-x: hidden;
  474. }
  475. </style>