graphy.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. <template>
  2. <div id="graphy" ref="graphy">
  3. <div v-show="!FloorMap">
  4. <div class="center" style="height: 400px;padding-top:182px;box-sizing:border-box;">
  5. <i class="icon-wushuju iconfont"></i>
  6. 暂无数据
  7. </div>
  8. </div>
  9. <div class="canvas-box" v-show="FloorMap" v-loading="canvasLoading">
  10. <canvas id="floorCanvas" :width="canvasWidth" :height="canvasHeight" ref="canvas" tabindex="0"></canvas>
  11. <!-- 初始两个按钮 -->
  12. <el-row class="buttons-box">
  13. <div>
  14. <el-autocomplete popper-class="my-autocomplete" v-model="search" :fetch-suggestions="querySearch" placeholder="输入平面图中已有的业务空间名称进行查找"
  15. width="180px" @select="handleSelect">
  16. <i class="el-icon-search el-input__icon" slot="suffix" @click="handleSelect"></i>
  17. <template slot-scope="{ item }">
  18. <div class="name" style="position: relative;">
  19. {{ item.data.RoomLocalName | cutString(8) }}
  20. <span class="addr" style="position: absolute;right:10px;color:#409EFF;">定位</span>
  21. </div>
  22. </template>
  23. </el-autocomplete>
  24. </div>
  25. <div class="button-group">
  26. <!-- 默认操作模式 -->
  27. <div v-show="type==1">
  28. <el-dropdown split-button type="primary" @click="editGraphy" @command="handleCommand">
  29. 创建业务空间
  30. <el-dropdown-menu slot="dropdown">
  31. <el-dropdown-item command="groupCreateBSpace">批量创建业务空间</el-dropdown-item>
  32. </el-dropdown-menu>
  33. </el-dropdown>
  34. </div>
  35. <!-- 点击已经关联的业务空间 -->
  36. <div v-show="type==2">
  37. <el-button type="primary" plain @click="refactorBSP">重新划分业务空间</el-button>
  38. <el-button type="primary" @click="editeSpaceDetail">编辑空间详情</el-button>
  39. <el-button plain @click="cancelGraphy">取 消</el-button>
  40. </div>
  41. <!-- 点击未关联的业务空间 -->
  42. <div v-show="type==3">
  43. <el-button plain @click="createNewZone">创建单个全新的业务空间</el-button>
  44. <el-button plain @click="lookUnrelatBSpace(true)">从未关联平面图的业务空间中选择</el-button>
  45. <el-button plain @click="cancelGraphy">取 消</el-button>
  46. </div>
  47. <!-- 重新划分业务空间 -->
  48. <div v-show="type==4">
  49. <el-button plain @click="cancelGraphy">取 消</el-button>
  50. <el-button type="primary" @click="saveRefactorBSP">保存</el-button>
  51. </div>
  52. <!-- 批量创建所选业务空间 -->
  53. <div v-show="type==5">
  54. <el-button type="primary" @click="groupCreateZone">批量创建所选业务空间</el-button>
  55. <el-button plain @click="cancelGraphy">取 消</el-button>
  56. </div>
  57. </div>
  58. <div style="position: absolute;right: 0;">
  59. <el-button type="text" @click="lookUnrelatBSpace(false)">未关联平面图的业务空间 {{num}} 条</el-button>
  60. </div>
  61. </el-row>
  62. <!-- 底部操作按钮 -->
  63. <el-row class="canvas-actions-box">
  64. <canvasFun @fit="fit" @savePng="savePng" @saveSvg="saveSvg" @divide="divide" @clearDivide="clearDivide" @undo="undo" @redo="redo"
  65. @changeAbsorb="changeAbsorb" @scale="scale" @groupSelect="groupSelect" :config="config" ref="canvasFun"></canvasFun>
  66. </el-row>
  67. </div>
  68. <!-- -->
  69. <!-- 未关联元空间的业务空间 -->
  70. <unRelateBSP ref="unRelateBSP" :isAction="isAction" @createFromUnrelated="createFromUnrelated" :code="tab.code"></unRelateBSP>
  71. <!-- 创建新的业务空间 -->
  72. <createBSP ref="createBSP" @createRoom="createRoom"></createBSP>
  73. <!-- 批量创建选择弹窗 -->
  74. <el-dialog title="提示" :visible.sync="groupCreateDialogVis" width="30%">
  75. <div id="autoRelate">
  76. <p>请选择批量创建方式:</p>
  77. <p>
  78. <el-radio v-model="groupCreateType" :label="1">批量将所有的空白空间创建业务空间</el-radio>
  79. </p>
  80. <p>
  81. <el-radio v-model="groupCreateType" :label="2">批量选择空白空间创建业务空间</el-radio>
  82. </p>
  83. </div>
  84. <span slot="footer" class="dialog-footer">
  85. <el-button size="small" @click="groupCreateDialogVis=false">取消</el-button>
  86. <el-button size="small" type="primary" @click="confirm">确认</el-button>
  87. </span>
  88. </el-dialog>
  89. </div>
  90. </template>
  91. <script>
  92. import canvasFun from "./canvasFun"
  93. import { mapGetters, mapActions } from "vuex";
  94. import { SColor, SPoint } from "@saga-web/draw/lib";
  95. import { DivideFloorScene, SpaceItem, ZoneItem } from "@saga-web/cad-engine/lib";
  96. import { FloorView } from "@saga-web/cad-engine/lib/FloorView";
  97. import unRelateBSP from "./unRelateBSP";
  98. import createBSP from "./createBSP";
  99. import {
  100. buildingQuery,
  101. queryZone,
  102. updateZone,
  103. createZone,
  104. countZone,
  105. getIspNotInSpace,
  106. createRelateInZoneAndISp,
  107. groupCreRelaZoneAndISp
  108. } from "@/api/scan/request"
  109. const colorArr = [
  110. "#F9C3C3",
  111. "#FFD1BF",
  112. "#FFF3BF",
  113. "#D8F7C6",
  114. "#C6F2F6",
  115. "#DCE3C0",
  116. "#FAE6C9",
  117. "#E3D7F7",
  118. "#C4CBF8",
  119. "#DEC3F6"
  120. ];
  121. // BSP => 业务空间
  122. export default {
  123. components: {
  124. canvasFun,
  125. unRelateBSP,
  126. createBSP
  127. },
  128. data() {
  129. return {
  130. canvasWidth: 800,
  131. canvasHeight: 600,
  132. type: 1, // 默认操作模式
  133. search: '',//搜索
  134. buildFloor: ['', ''],
  135. FloorObj: {}, //楼层对象
  136. FloorMap: '', //楼层底图
  137. tab: {},
  138. config: {
  139. isEdit: false,
  140. divide: true,
  141. groupSelect: true
  142. },
  143. canvasLoading: false,
  144. view: null,
  145. scene: null,
  146. Outline: [], // 当前选中的多个空间组成的轮廓线->三维数组
  147. businessSpaceList: [], // 所有业务空间
  148. num: 0, // 未关联元空间的业务空间统计
  149. BSPRelaISPList: [], // 已关联元空间的业务空间
  150. // 未关联元空间的业务空间弹窗
  151. isAction: false,
  152. curOutline: [],
  153. BIMIDToSID: {}, //bimid映射元空间id
  154. curZoneItem: {}, //当前选中的业务空间item
  155. allUnRelatISP: [], //
  156. zoneList: [], // 业务空间-canvas图中
  157. groupCreateDialogVis: false, //批量创建业务空间弹窗
  158. groupCreateType: 1, //批量创建方式
  159. }
  160. },
  161. computed: {
  162. ...mapGetters('layout', ['projectId'])
  163. },
  164. created() {
  165. },
  166. mounted() {
  167. this.canvasWidth = this.$refs.graphy.offsetWidth;
  168. this.canvasHeight = this.$refs.graphy.offsetHeight;
  169. },
  170. methods: {
  171. // 初始化
  172. init(initType) {
  173. this.type = 1;
  174. if (this.scene) {
  175. this.scene.isZoneSelectable = true;
  176. this.scene.isSpaceSelectable = true;
  177. this.scene.clearSpaceSelection();
  178. this.scene.clearZoneSelection();
  179. }
  180. if (this.buildFloor.indexOf('all') > -1 || this.buildFloor.indexOf('noKnow') > -1) {
  181. return;
  182. }
  183. if (initType == 1) {
  184. // 底图
  185. this.getGraphy();
  186. } else {
  187. // 业务空间
  188. this.getBusinessSpace();
  189. }
  190. this.config = {
  191. isEdit: false,
  192. divide: true,
  193. groupSelect: true
  194. }
  195. // 获取当前楼层的元空间
  196. this.getFloorISpace();
  197. // 查询未关联业务空间的元空间
  198. this.getISPSPUnrelaBSP();
  199. // 查询未关联平面图的业务空间
  200. this.getBSPunrelaISP();
  201. },
  202. // 获取当前楼层的元空间
  203. getFloorISpace() {
  204. let pa = {
  205. zone: 'Ispace',
  206. data: {
  207. Filters: `FloorId='${this.buildFloor[1]}'`,
  208. PageSize: 1000
  209. }
  210. }
  211. queryZone(pa, res => {
  212. this.BIMIDToSID = {}
  213. res.Content.map(t => {
  214. this.BIMIDToSID[t.BIMID.split(":")[1]] = t.RoomID;
  215. })
  216. })
  217. },
  218. // 搜索
  219. querySearch(queryString, cb) {
  220. let restaurants = this.zoneList;
  221. let results = queryString ?
  222. restaurants.filter(this.createFilter(queryString)) :
  223. restaurants;
  224. // 调用 callback 返回建议列表的数据
  225. cb(results);
  226. },
  227. // 过滤器
  228. createFilter(queryString) {
  229. return restaurant => {
  230. return restaurant.data.RoomLocalName.indexOf(queryString) > -1;
  231. };
  232. },
  233. // 查询选中,定位
  234. handleSelect(zone) {
  235. // 清空选中
  236. this.scene.clearSpaceSelection();
  237. this.scene.clearZoneSelection();
  238. // 选中当前
  239. zone.selected = true;
  240. this.curZoneItem = zone;
  241. this.type = 2;
  242. this.view.fitSelectedToView();
  243. },
  244. // 父组件调用
  245. getData(buildFloor, FloorObj, tab) {
  246. let initType = 1;
  247. if (FloorObj.FloorID == this.FloorObj.FloorID) {
  248. initType = 2;
  249. }
  250. this.buildFloor = buildFloor;
  251. this.FloorObj = FloorObj;
  252. this.FloorMap = FloorObj.StructureInfo ? FloorObj.StructureInfo.FloorMap : ''
  253. this.tab = tab;
  254. console.log(arguments)
  255. this.init(initType);
  256. },
  257. // 获取未绑定业务空间的元空间
  258. getISPSPUnrelaBSP() {
  259. let pa = {
  260. data: {
  261. Filters: `FloorId='${this.buildFloor[1]}'`,
  262. PageSize: 1000
  263. },
  264. objectType: this.tab.code
  265. }
  266. this.allUnRelatISP = []
  267. getIspNotInSpace(pa, res => {
  268. this.allUnRelatISP = res.Content;
  269. })
  270. },
  271. // 获取底图
  272. getGraphy() {
  273. let that = this;
  274. that.clearGraphy()
  275. that.scene = new DivideFloorScene();
  276. that.canvasLoading = true;
  277. that.scene.loadUrl(`/image-service/common/file_get?systemId=revit&key=${this.FloorMap}`).then(res => {
  278. that.canvasLoading = false;
  279. if (res == 'error') {
  280. this.FloorMap = '';
  281. this.$message.warning('数据解析异常');
  282. return;
  283. }
  284. that.view.scene = that.scene;
  285. // 蒙版
  286. if (this.FloorObj.Outline) {
  287. let newArr = this.FloorObj.Outline.map(t => {
  288. return new SPoint(t.X, t.Y);
  289. })
  290. this.scene.addSceneMark(newArr)
  291. }
  292. // 绘制业务空间
  293. that.getBusinessSpace();
  294. that.view.fitSceneToView();
  295. that.view.maxScale = that.view.scale * 10;
  296. that.view.minScale = that.view.scale;
  297. if (that.$refs.canvasFun) {
  298. that.$refs.canvasFun.everyScale = that.view.scale;
  299. }
  300. })
  301. },
  302. // 清空绘制业务空间
  303. clearZoneCanvas() {
  304. this.zoneList.map(t => {
  305. this.scene.removeItem(t);
  306. })
  307. },
  308. // 获取当前分区下的业务空间
  309. getBusinessSpace() {
  310. this.canvasLoading = true
  311. let pa = {
  312. zone: this.tab.code,
  313. data: {
  314. Filters: ``,
  315. Orders: "createTime desc, RoomID asc",
  316. PageSize: 1000
  317. }
  318. }
  319. if (this.buildFloor.length && this.buildFloor.length > 1) {
  320. pa.data.Filters = `BuildingId='${this.buildFloor[0]}';FloorId='${this.buildFloor[1]}'`
  321. }
  322. this.clearZoneCanvas();
  323. queryZone(pa, res => {
  324. // 所有业务空间
  325. this.businessSpaceList = res.Content;
  326. // 已关联元空间的业务空间
  327. this.BSPRelaISPList = [];
  328. res.Content.map(t => {
  329. if (t.Outline && t.Outline.length) {
  330. this.BSPRelaISPList.push(t)
  331. }
  332. })
  333. // 绘制业务空间
  334. let tempArr = this.BSPRelaISPList.map((t, i) => {
  335. return {
  336. RoomLocalName: t.RoomLocalName,
  337. OutLine: t.Outline,
  338. RoomID: t.RoomID,
  339. Color: new SColor(colorArr[i % colorArr.length]),
  340. }
  341. })
  342. this.scene.zoneList = [];
  343. this.scene.addZoneList(tempArr);
  344. this.scene.click(this, this.canvasClick);
  345. this.zoneList = this.scene.zoneList;
  346. this.canvasLoading = false;
  347. })
  348. },
  349. // canvas点击事件
  350. canvasClick(item, event) {
  351. console.log(item)
  352. console.log(event)
  353. if (this.type == 4) {
  354. } else {
  355. if (item instanceof SpaceItem && item.selectable) {
  356. if (this.type == 2) {
  357. this.scene.clearZoneSelection();
  358. }
  359. this.type = 3;
  360. this.curZoneItem = {};
  361. }
  362. if (item instanceof ZoneItem && item.selectable) {
  363. if (this.type == 3) {
  364. this.scene.clearSpaceSelection();
  365. }
  366. this.type = 2;
  367. this.curZoneItem = item;
  368. this.scene.clearZoneSelection();
  369. item.selected = true;
  370. }
  371. }
  372. },
  373. // 编辑平面图
  374. editGraphy() {
  375. this.type = 3;
  376. this.config.isEdit = true;
  377. this.config.groupSelect = false;
  378. this.config.divide = true;
  379. // 设置业务空间不可选
  380. this.scene.isZoneSelectable = false
  381. },
  382. // 查看未关联的业务空间--flag--查看-or-选择
  383. lookUnrelatBSpace(flag) {
  384. this.isAction = flag;
  385. let arr = this.scene.getSelectedSpaces();
  386. if (flag && !arr.length) {
  387. this.$message.warning('请至少选择一个空间');
  388. return;
  389. }
  390. this.$refs.unRelateBSP.showDialog();
  391. },
  392. // 取消(所有取消公用)
  393. cancelGraphy() {
  394. this.init(2);
  395. },
  396. // 批量创建业务空间弹窗
  397. handleCommand(command) {
  398. this.groupCreateDialogVis = true;
  399. },
  400. // 创建弹窗确认
  401. confirm() {
  402. if (this.groupCreateType == 1) {
  403. this.groupCreateBSpace()
  404. } else if (this.groupCreateType == 2) {
  405. this.type = 5;
  406. this.config.isEdit = true;
  407. this.config.groupSelect = true;
  408. this.config.divide = false;
  409. this.groupCreateDialogVis = false;
  410. // 清空选中空间
  411. this.scene.clearSpaceSelection();
  412. // 设置空间可选
  413. this.scene.isSpaceSelectable = true;
  414. // 设置业务空间不可选
  415. this.scene.isZoneSelectable = false;
  416. }
  417. },
  418. // 批量创建业务空间
  419. groupCreateBSpace() {
  420. let text = []
  421. let Spaces = this.allUnRelatISP.map(t => {
  422. if (t.Outline) {
  423. text.push(t.RoomLocalName || t.RoomName)
  424. return {
  425. IspaceId: t.RoomID,
  426. RoomLocalName: t.RoomLocalName || t.RoomName,
  427. Outline: [t.Outline],
  428. BuildingId: this.buildFloor[0],
  429. FloorId: this.buildFloor[1],
  430. Height: t.Height || 0
  431. }
  432. } else {
  433. return undefined
  434. }
  435. }).filter(item => item);
  436. if (Spaces.length) {
  437. this.$confirm(
  438. "<p>确定根据未关联业务空间的空间批量创建业务空间</p>" +
  439. "<p>涉及的空间:</p>" +
  440. "<p style='line-height:20px;max-height:60px;overflow-y:auto;'>" +
  441. text.toString() +
  442. "</p>",
  443. "提示", {
  444. dangerouslyUseHTMLString: true,
  445. confirmButtonText: "确定",
  446. cancelButtonText: "取消",
  447. type: "warning"
  448. }
  449. ).then(() => {
  450. this.canvasLoading = true;
  451. this.groupCreateBSP(Spaces)
  452. }).catch(() => {
  453. this.$message({
  454. type: "info",
  455. message: "已取消批量创建"
  456. });
  457. });
  458. } else {
  459. this.$message('没有未关联的元空间')
  460. }
  461. },
  462. // 创建新的业务空间
  463. createNewZone() {
  464. let arr = this.scene.getSelectedSpaces();
  465. if (arr.length) {
  466. let tempArr = [];
  467. arr.map(t => {
  468. tempArr.push(t.data.Name);
  469. })
  470. this.$refs.createBSP.showDialog(tempArr.toString());
  471. } else {
  472. this.$message.warning('请至少选择一个空间');
  473. }
  474. },
  475. // 创建新的业务空间-弹窗返回确认创建
  476. createRoom(val) {
  477. let arr = this.scene.getSelectedSpaces();
  478. let zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
  479. arr.map(t => {
  480. zoneObj.Outline.push(t.data.OutLine);
  481. IspaceIdList.push(this.BIMIDToSID[t.data.SourceId]);
  482. console.log(zoneObj.Height)
  483. if (t.data.Height && (zoneObj.Height == 0 || t.data.Height < zoneObj.Height)) {
  484. zoneObj.Height = t.data.Height;
  485. }
  486. })
  487. zoneObj.RoomLocalName = val;
  488. zoneObj.BuildingId = this.buildFloor[0];
  489. zoneObj.FloorId = this.buildFloor[1];
  490. this.createSingleBSP(zoneObj, IspaceIdList)
  491. },
  492. // 从未关联平面图的业务空间中选择--按钮返回关联信号
  493. createFromUnrelated(BSP) {
  494. BSP.Outline = [];
  495. BSP.Height = 0;
  496. let arr = this.scene.getSelectedSpaces(), IspaceIdList = [];
  497. arr.map(t => {
  498. BSP.Outline.push(t.data.OutLine);
  499. IspaceIdList.push(this.BIMIDToSID[t.data.SourceId]);
  500. if (t.Height && (BSP.Height == 0 || t.Height < BSP.Height)) {
  501. BSP.Height = t.Height;
  502. }
  503. })
  504. this.updateBSPOutline(BSP, IspaceIdList)
  505. },
  506. // 编辑空间详情
  507. editeSpaceDetail() {
  508. let item = this.curZoneItem.data;
  509. this.$router.push({
  510. path: "/ledger/spaceDetail",
  511. query: { RoomID: item.RoomID, zone: this.tab.code, isMyTab: 1 }
  512. })
  513. },
  514. // 重新划分业务空间
  515. refactorBSP() {
  516. this.type = 4;
  517. // 清空选中空间
  518. this.scene.clearSpaceSelection();
  519. // 设置空间可选
  520. this.scene.isSpaceSelectable = true;
  521. // 将已关联的设置不可选,并将当前选的隐藏
  522. this.scene.isZoneSelectable = false;
  523. this.curZoneItem.visible = false;
  524. },
  525. // 重新划分--保存
  526. saveRefactorBSP() {
  527. let arr = this.scene.getSelectedSpaces();
  528. //更新业务空间
  529. let zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
  530. arr.map(t => {
  531. zoneObj.Outline.push(t.data.OutLine);
  532. IspaceIdList.push(this.BIMIDToSID[t.data.SourceId]);
  533. if (t.Height && (zoneObj.Height == 0 || t.Height < zoneObj.Height)) {
  534. zoneObj.Height = t.Height;
  535. }
  536. })
  537. zoneObj.RoomID = this.curZoneItem.data.RoomID;
  538. if (!zoneObj.Outline.length) {
  539. zoneObj.Outline = null;
  540. }
  541. this.updateBSPOutline(zoneObj, IspaceIdList)
  542. },
  543. // 批量创建所选业务空间
  544. groupCreateZone() { },
  545. // 更新业务空间和元空间的关系
  546. relationInBSPandISP(SpaceId, IspaceIdList) {
  547. let pa = {
  548. data: { SpaceId: SpaceId, IspaceIdList: IspaceIdList },
  549. type: this.tab.code
  550. }
  551. createRelateInZoneAndISp(pa, res => {
  552. this.$message.success('创建成功');
  553. this.init(2);
  554. })
  555. },
  556. // 批量更新业务空间和元空间的关系
  557. groupCreRelaZoneAndISp(Spaces) {
  558. let param = {
  559. data: {
  560. Content: Spaces
  561. },
  562. type: this.tab.code
  563. }
  564. groupCreRelaZoneAndISp(param, res => {
  565. this.$message.success('创建成功')
  566. this.canvasLoading = false;
  567. this.init(2)
  568. })
  569. },
  570. // 批量创建
  571. groupCreateBSP(spaces) {
  572. let pa = {
  573. zone: this.tab.code,
  574. data: {
  575. Content: space
  576. }
  577. }
  578. createZone(pa, res => {
  579. res.EntityList.map(t => {
  580. Spaces = Spaces.map(item => {
  581. if (t.RoomLocalName == item.RoomLocalName) {
  582. item.SpaceId = t.RoomID
  583. }
  584. return item;
  585. })
  586. })
  587. this.groupCreRelaZoneAndISp(space)
  588. })
  589. },
  590. // 单个创建
  591. createSingleBSP(space, IspaceIdList) {
  592. let pa = {
  593. zone: this.tab.code,
  594. data: {
  595. Content: [space]
  596. }
  597. }
  598. createZone(pa, res => {
  599. this.relationInBSPandISP(res.EntityList[0].RoomID, IspaceIdList)
  600. })
  601. },
  602. // 更新业务空间区域
  603. updateBSPOutline(zoneObj, IspaceIdList) {
  604. let pa = {
  605. zone: this.tab.code,
  606. data: {
  607. Content: [zoneObj],
  608. Projection: ['Outline']
  609. },
  610. }
  611. updateZone(pa, res => {
  612. this.relationInBSPandISP(zoneObj.RoomID, IspaceIdList)
  613. })
  614. },
  615. // 查询未关联平面图的业务空间(项目下+当前分区)
  616. getBSPunrelaISP() {
  617. let pa = {
  618. zone: this.tab.code,
  619. data: {
  620. Filters: `Outline isNull`
  621. }
  622. }
  623. countZone(pa, res => {
  624. this.num = res.Count;
  625. })
  626. },
  627. // canvas 获取焦点
  628. focus() {
  629. document.getElementById(`floorCanvas`).focus()
  630. },
  631. // 清除canvas
  632. clearGraphy() {
  633. if (this.view && this.view.scene) {
  634. this.view.scene = null;
  635. return
  636. }
  637. this.view = new FloorView('floorCanvas')
  638. },
  639. // 工具栏操作
  640. // 吸附
  641. changeAbsorb(isAbsorbing) {
  642. this.scene.isAbsorbing = isAbsorbing;
  643. },
  644. // 框选
  645. groupSelect() {
  646. this.scene.isRectSelection = true;
  647. },
  648. // 适配底图到窗口
  649. fit() {
  650. this.view.fitSceneToView()
  651. },
  652. // 保存为png
  653. savePng() {
  654. this.view.saveImage(`${this.buildFloor[1]}.png`, 'png');
  655. },
  656. // 保存为svg
  657. saveSvg() {
  658. this.view.saveSceneSvg(`${this.buildFloor[1]}.svg`, 6400, 4800);
  659. },
  660. // 切割划分
  661. divide() {
  662. this.scene.isMarking = true;
  663. },
  664. // 清除切割划分
  665. clearDivide() {
  666. this.scene.clearSceneMark()
  667. },
  668. // 撤销
  669. undo() {
  670. },
  671. // 反撤销
  672. redo() { },
  673. // 缩放
  674. scale(val) {
  675. if (!this.view) {
  676. return;
  677. }
  678. let scale = this.view.scale;
  679. this.view.scaleByPoint(val / scale, this.canvasWidth / 2, this.canvasHeight / 2);
  680. },
  681. },
  682. filters: {
  683. cutString: function (str, len) {
  684. //length属性读出来的汉字长度为1
  685. if (!!str && typeof str == "string" && str.length > len) {
  686. return str.substring(0, len) + "...";
  687. } else {
  688. return str || "--";
  689. }
  690. }
  691. },
  692. watch: {
  693. projectId() {
  694. this.FloorMap = '';
  695. this.tab = {};
  696. },
  697. "view.scale": {
  698. handler(n) {
  699. if (this.$refs.canvasFun) {
  700. this.$refs.canvasFun.sliderVal = n * 10 / this.view.minScale;
  701. }
  702. }
  703. }
  704. }
  705. }
  706. </script>
  707. <style lang="less" scoped>
  708. #graphy {
  709. position: relative;
  710. width: 100%;
  711. height: calc(100% - 56px);
  712. .canvas-box {
  713. width: 100%;
  714. height: 100%;
  715. }
  716. .buttons-box {
  717. position: absolute;
  718. top: 0;
  719. width: 100%;
  720. z-index: 999;
  721. & > div {
  722. float: left;
  723. }
  724. /deep/ .el-autocomplete {
  725. display: block;
  726. width: 320px;
  727. margin-right: 10px;
  728. }
  729. .button-group button {
  730. display: block;
  731. float: left;
  732. }
  733. .my-autocomplete {
  734. li {
  735. line-height: normal;
  736. padding: 7px;
  737. .name {
  738. text-overflow: ellipsis;
  739. overflow: hidden;
  740. }
  741. .addr {
  742. font-size: 12px;
  743. color: #b4b4b4;
  744. }
  745. .highlighted .addr {
  746. color: #ddd;
  747. }
  748. }
  749. }
  750. }
  751. .canvas-actions-box {
  752. position: absolute;
  753. bottom: 20px;
  754. left: 50%;
  755. transform: translateX(-50%);
  756. z-index: 999;
  757. }
  758. }
  759. </style>