graphy.vue 21 KB

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