graphy.vue 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271
  1. <template>
  2. <div id="graphy" ref="graphy" v-loading="canvasLoading">
  3. <div v-show="!FloorMap">
  4. <div style="margin-right:10px;width: 100%;margin-bottom: 10px" v-if="showOtherFlag">
  5. <!-- 平面图其他分区 -->
  6. <el-button type="primary" @click="addZoneBtn">添加分区</el-button>
  7. <el-select v-model="OtherValue" placeholder="请选择分区类型" @change="changeOtherZone">
  8. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
  9. </el-option>
  10. </el-select>
  11. </div>
  12. <div class="center" style="height: 400px;padding-top:182px;box-sizing:border-box;">
  13. <i class="icon-wushuju iconfont"></i>
  14. 暂无数据
  15. </div>
  16. </div>
  17. <div class="canvas-box" v-show="FloorMap">
  18. <canvas id="floorCanvas" :width="canvasWidth" :height="canvasHeight" ref="canvas" tabindex="0"></canvas>
  19. <!-- 初始两个按钮 -->
  20. <el-row class="buttons-box">
  21. <div style="margin-right:10px;width: 100%;margin-bottom: 10px" v-if="showOtherFlag">
  22. <!-- 平面图其他分区 -->
  23. <el-button type="primary" @click="addZoneBtn">添加分区</el-button>
  24. <el-select v-model="OtherValue" placeholder="请选择分区类型" @change="changeOtherZone">
  25. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
  26. </el-option>
  27. </el-select>
  28. </div>
  29. <div>
  30. <el-autocomplete popper-class="my-autocomplete" v-model="search" :fetch-suggestions="querySearch" placeholder="输入平面图中已有的业务空间名称进行查找"
  31. width="180px" @select="handleSelect">
  32. <i class="el-icon-search el-input__icon" slot="suffix" @click="handleSelect"></i>
  33. <template slot-scope="{ item }">
  34. <div class="name" style="position: relative;padding-right:40px;overflow: hidden;text-overflow:ellipsis;white-space: nowrap;"
  35. :title="item.data.RoomLocalName">
  36. {{ item.data.RoomLocalName }}
  37. <span class="addr" style="position: absolute;right:0;color:#409EFF;">定位</span>
  38. </div>
  39. </template>
  40. </el-autocomplete>
  41. </div>
  42. <div class="button-group">
  43. <!-- 默认操作模式 -->
  44. <div v-show="type==1">
  45. <el-dropdown split-button type="primary" @click="editGraphy" @command="handleCommand">
  46. 创建业务空间
  47. <el-dropdown-menu slot="dropdown">
  48. <el-dropdown-item command="groupCreateBSpace">批量创建业务空间</el-dropdown-item>
  49. </el-dropdown-menu>
  50. </el-dropdown>
  51. <!-- 点击已经关联的业务空间 -->
  52. <el-button type="primary" plain @click="refactorBSP" :disabled="zoneDisable" style="margin-left:10px;">重新划分业务空间</el-button>
  53. <el-button type="primary" @click="editeSpaceDetail" :disabled="zoneDisable">编辑空间详情</el-button>
  54. <el-button type="primary" plain @click="confirmZoneSpace" :disabled="zoneDisable||(!zoneDisable&&!curZoneItem.isInfected)">确认业务空间
  55. </el-button>
  56. <el-button plain @click="cancelGraphy" v-show="!zoneDisable">取 消</el-button>
  57. </div>
  58. <!-- 点击已经关联的业务空间 -->
  59. <!-- <div v-show="type==2">
  60. </div> -->
  61. <!-- 点击未关联的业务空间 -->
  62. <div v-show="type==3">
  63. <el-button plain @click="createNewZone">创建单个全新的业务空间</el-button>
  64. <el-button plain @click="lookUnrelatBSpace(true)">从未关联平面图的业务空间中选择</el-button>
  65. <el-button plain @click="cancelGraphy">取 消</el-button>
  66. </div>
  67. <!-- 重新划分业务空间 -->
  68. <div v-show="type==4">
  69. <el-button plain @click="cancelGraphy">取 消</el-button>
  70. <el-button type="primary" @click="saveRefactorBSP">保存</el-button>
  71. <el-button type="primary" v-show='curZoneItem.isInfected' @click="confirmAndSave">保存并确认业务空间</el-button>
  72. </div>
  73. <!-- 批量创建所选业务空间 -->
  74. <div v-show="type==5">
  75. <el-button type="primary" @click="groupCreateZone">批量创建所选业务空间</el-button>
  76. <el-button plain @click="cancelGraphy">取 消</el-button>
  77. </div>
  78. <div style="position: absolute;right: 10px;">
  79. <el-button type="text" @click="lookUnrelatBSpace(false)">未关联平面图的业务空间 {{num}} 条</el-button>
  80. </div>
  81. </div>
  82. </el-row>
  83. <!-- 底部操作按钮 -->
  84. <el-row class="canvas-actions-box">
  85. <canvasFun @fit="fit" @savePng="savePng" @saveSvg="saveSvg" @divide="divide" @clearDivide="clearDivide" @undo="undo" @redo="redo"
  86. @changeAbsorb="changeAbsorb" @scale="scale" @groupSelect="groupSelect" :config="config" ref="canvasFun" @saveJson="saveJson"></canvasFun>
  87. </el-row>
  88. </div>
  89. <!-- -->
  90. <!-- 未关联元空间的业务空间 -->
  91. <unRelateBSP ref="unRelateBSP" :isAction="isAction" @createFromUnrelated="createFromUnrelated" :code="tab.code"></unRelateBSP>
  92. <!-- 创建新的业务空间 -->
  93. <createBSP ref="createBSP" @createRoom="createRoom"></createBSP>
  94. <!-- 批量创建选择弹窗 -->
  95. <el-dialog title="提示" :visible.sync="groupCreateDialogVis" width="30%" :close-on-click-modal="false">
  96. <div id="autoRelate">
  97. <p>批量创建面积大于此值的默认空间为业务空间:</p>
  98. <div style="padding:10px 20px;margin:0 0 10px 0;">
  99. <el-slider v-model="areaValue" :marks="areaMarks" :step="10" :format-tooltip='val=>val/100'> </el-slider>
  100. </div>
  101. <p>请选择批量创建方式:</p>
  102. <p>
  103. <el-radio v-model="groupCreateType" :label="1">批量将所有的空白空间创建业务空间</el-radio>
  104. </p>
  105. <p>
  106. <el-radio v-model="groupCreateType" :label="2">批量选择空白空间创建业务空间</el-radio>
  107. </p>
  108. </div>
  109. <span slot="footer" class="dialog-footer">
  110. <el-button size="small" @click="groupCreateDialogVis=false">取消</el-button>
  111. <el-button size="small" type="primary" @click="confirm">确认</el-button>
  112. </span>
  113. </el-dialog>
  114. <dialogZone ref="zone" @createSuccess="getOtherType" />
  115. </div>
  116. </template>
  117. <script>
  118. import canvasFun from "./canvasFun"
  119. import { mapGetters } from "vuex";
  120. import { SPoint, SColor } from "@saga-web/draw/lib";
  121. import { DivideFloorScene, FloorView, SpaceItem, ZoneItem, Opt } from "@saga-web/cad-engine/lib";
  122. import { colorArr } from "@/utils/spaceColor"
  123. import unRelateBSP from "./unRelateBSP";
  124. import createBSP from "./createBSP";
  125. import dialogZone from "../../ledger/addDialog/dialogZone";
  126. import {
  127. createRelateInZoneAndISp,
  128. getIspNotInSpace,
  129. groupCreRelaZoneAndISp,
  130. queryAllZoneType,
  131. queryZone,
  132. zoneCount,
  133. zoneCreate,
  134. zoneQuery,
  135. zoneUpdate,
  136. handleZoneUpdateBd
  137. } from "@/api/scan/request"
  138. export default {
  139. components: {
  140. canvasFun,
  141. unRelateBSP,
  142. createBSP,
  143. dialogZone
  144. },
  145. data() {
  146. return {
  147. canvasWidth: 800,
  148. canvasHeight: 600,
  149. type: 1, // 默认操作模式
  150. search: '',//搜索
  151. buildFloor: ['', ''],
  152. FloorObj: {}, //楼层对象
  153. FloorMap: '', //楼层底图
  154. tab: {},
  155. config: {
  156. isEdit: false,
  157. divide: true,
  158. groupSelect: true
  159. },
  160. canvasLoading: false,
  161. view: null,
  162. scene: null,
  163. Outline: [], // 当前选中的多个空间组成的轮廓线->三维数组
  164. businessSpaceList: [], // 所有业务空间
  165. num: 0, // 未关联元空间的业务空间统计
  166. BSPRelaISPList: [], // 已关联元空间的业务空间
  167. // 未关联元空间的业务空间弹窗
  168. isAction: false,
  169. curOutline: [],
  170. BIMIDToSID: {}, //bimid映射元空间id
  171. BIMIDToSIName: {}, //bimid映射元空间名称
  172. curZoneItem: {}, //当前选中的业务空间item
  173. allUnRelatISP: [], //
  174. zoneList: [], // 业务空间-canvas图中
  175. groupCreateDialogVis: false, //批量创建业务空间弹窗
  176. groupCreateType: 1, //批量创建方式
  177. zoneDisable: true, // 重新划分是否禁用
  178. sourceIdToISP: {},
  179. areaValue: 40,
  180. areaMarks: { 0: '0m²', 100: '1m²' },
  181. options: [], //其他分区类型
  182. OtherValue: '',
  183. showOtherFlag: false, //是否显示其他分区类型添加
  184. }
  185. },
  186. computed: {
  187. ...mapGetters('layout', ['projectId'])
  188. },
  189. created() {
  190. Opt.sceneMarkColor = new SColor('#ffffff');
  191. },
  192. mounted() {
  193. this.canvasWidth = this.$refs.graphy.offsetWidth - 20;
  194. this.canvasHeight = this.$refs.graphy.offsetHeight - 20;
  195. },
  196. methods: {
  197. // 初始化
  198. init(initType) {
  199. this.type = 1;
  200. if (this.scene) {
  201. this.scene.clearSpaceSelection();
  202. this.scene.clearZoneSelection();
  203. this.scene.clearCut();
  204. this.scene.clearLikeSpaces();
  205. this.zoneDisable = true;
  206. this.scene.isZoneSelectable = true;
  207. this.scene.isSpaceSelectable = false;
  208. }
  209. if (this.buildFloor.indexOf('all') > -1 || this.buildFloor.indexOf('noKnow') > -1) {
  210. return;
  211. }
  212. if (initType == 1) {
  213. // 底图
  214. this.getGraphy();
  215. } else {
  216. // 业务空间
  217. this.getBusinessSpace();
  218. }
  219. this.config = {
  220. isEdit: false,
  221. divide: true,
  222. groupSelect: true
  223. }
  224. // 获取当前楼层的元空间
  225. this.getFloorISpace();
  226. // 查询未关联业务空间的元空间
  227. this.getISPSPUnrelaBSP();
  228. // 查询未关联平面图的业务空间
  229. this.getBSPunrelaISP();
  230. },
  231. // 获取当前楼层的元空间-元空间接口不变
  232. getFloorISpace() {
  233. let pa = {
  234. zone: 'Ispace',
  235. data: {
  236. Filters: `FloorId='${this.buildFloor[1]}'`,
  237. PageSize: 1000
  238. }
  239. }
  240. queryZone(pa, res => {
  241. this.BIMIDToSID = {}
  242. this.BIMIDToSIName = {}
  243. this.sourceIdToISP = {}
  244. res.Content.map(t => {
  245. let key = t.BIMID.split(":")[1];
  246. this.BIMIDToSID[key] = t.RoomID;
  247. this.BIMIDToSIName[key] = t.RoomLocalName || t.RoomName;
  248. this.sourceIdToISP[key] = t;
  249. })
  250. })
  251. },
  252. //添加其他分区
  253. addZoneBtn() {
  254. this.$refs.zone.dialogFormVisible = true
  255. },
  256. // 搜索
  257. querySearch(queryString, cb) {
  258. let restaurants = this.zoneList;
  259. let results = queryString ?
  260. restaurants.filter(this.createFilter(queryString)) :
  261. restaurants;
  262. // 调用 callback 返回建议列表的数据
  263. cb(results);
  264. },
  265. // 过滤器
  266. createFilter(queryString) {
  267. return restaurant => {
  268. return restaurant.data.RoomLocalName.indexOf(queryString) > -1;
  269. };
  270. },
  271. // 查询选中,定位
  272. handleSelect(zone) {
  273. // 清空选中
  274. this.scene.clearSpaceSelection();
  275. this.scene.clearZoneSelection();
  276. // 选中当前
  277. zone.selected = true;
  278. this.curZoneItem = zone;
  279. this.zoneDisable = false;
  280. this.view.fitSelectedToView();
  281. },
  282. // 父组件调用
  283. getData(buildFloor, FloorObj, tab) {
  284. let initType = 1;
  285. if (FloorObj.FloorID == this.FloorObj.FloorID) {
  286. initType = 2;
  287. }
  288. this.buildFloor = buildFloor;
  289. this.FloorObj = FloorObj;
  290. this.FloorMap = FloorObj.StructureInfo ? FloorObj.StructureInfo.FloorMap : ''
  291. this.tab = tab;
  292. console.log(arguments);
  293. if (tab.code == "OtherZone") {
  294. // 其他分区
  295. this.showOtherFlag = true
  296. this.getOtherType();
  297. this.OtherValue = (localStorage.getItem('otherZone')) || ''
  298. } else {
  299. this.showOtherFlag = false;
  300. }
  301. this.init(initType);
  302. },
  303. // 其他分区类型查询
  304. getOtherType() {
  305. let pa = {
  306. Cascade: [{ Name: 'zoneType', Filters: `ProjectId='${this.projectId}'` }],
  307. Filters: `Code="OtherZone"`
  308. }
  309. queryAllZoneType(pa, res => {
  310. if (res.Content[0].ZoneType && res.Content[0].ZoneType.length) {
  311. this.options = res.Content[0].ZoneType.map(t => {
  312. t.value = t.Code;
  313. t.label = t.Name;
  314. return t;
  315. })
  316. } else {
  317. this.options = []
  318. }
  319. })
  320. },
  321. // 其他类型下拉change
  322. changeOtherZone(val) {
  323. this.init(2);
  324. localStorage.setItem('otherZone', val)
  325. },
  326. // 获取未绑定业务空间的元空间
  327. getISPSPUnrelaBSP() {
  328. let pa = {
  329. data: {
  330. Filters: `FloorId='${this.buildFloor[1]}'`,
  331. PageSize: 1000
  332. },
  333. objectType: this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code
  334. }
  335. this.allUnRelatISP = []
  336. getIspNotInSpace(pa, res => {
  337. this.allUnRelatISP = res.Content;
  338. })
  339. },
  340. // 获取底图
  341. getGraphy() {
  342. let that = this;
  343. that.clearGraphy()
  344. that.scene = new DivideFloorScene();
  345. that.canvasLoading = true;
  346. that.scene.loadUrl(`/image-service/common/file_get?systemId=revit&key=${this.FloorMap}`).then(res => {
  347. that.canvasLoading = false;
  348. if (res == 'error') {
  349. this.FloorMap = '';
  350. this.$message.warning('数据解析异常');
  351. return;
  352. }
  353. that.view.scene = that.scene;
  354. // 蒙版
  355. if (this.FloorObj.Outline) {
  356. let newArr = this.FloorObj.Outline.map(t => {
  357. return new SPoint(t.X, t.Y);
  358. })
  359. this.scene.addSceneMark(newArr)
  360. }
  361. this.scene.isSpaceSelectable = false;
  362. // 绘制业务空间
  363. that.getBusinessSpace();
  364. that.fit();
  365. that.view.minScale = that.view.scale;
  366. if (that.$refs.canvasFun) {
  367. that.$refs.canvasFun.everyScale = that.view.scale;
  368. }
  369. })
  370. },
  371. // 获取当前分区下的业务空间
  372. getBusinessSpace() {
  373. this.canvasLoading = true
  374. let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
  375. let pa = {
  376. ZoneType: ObjectType,
  377. Filters: `not RoomID isNull`,
  378. Orders: "createTime desc, RoomID asc",
  379. PageSize: 10000
  380. }
  381. if (this.buildFloor.length && this.buildFloor.length > 1) {
  382. pa.BuildingId = this.buildFloor[0];
  383. pa.FloorId = this.buildFloor[1];
  384. }
  385. zoneQuery(pa, res => {
  386. // 所有业务空间
  387. this.businessSpaceList = res.Content;
  388. // 已关联元空间的业务空间
  389. this.BSPRelaISPList = [];
  390. res.Content.map(t => {
  391. if (t.Outline && t.Outline.length) {
  392. this.BSPRelaISPList.push(t)
  393. }
  394. })
  395. // 绘制业务空间
  396. let tempType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
  397. let tempArr = this.BSPRelaISPList.map((t, i) => {
  398. if (t.FloorId == this.buildFloor[1] && t.ObjectType == tempType) {
  399. return {
  400. RoomLocalName: t.RoomLocalName,
  401. OutLine: t.Outline,
  402. RoomID: t.RoomID,
  403. Color: colorArr[i % colorArr.length],
  404. Infected: t.State
  405. }
  406. } else {
  407. console.log('internet slow')
  408. return undefined;
  409. }
  410. }).filter(item => item)
  411. this.scene.removeAllZone();
  412. this.scene.addZoneList(tempArr);
  413. this.scene.click(this, this.canvasClick);
  414. this.zoneList = this.scene.zoneList;
  415. this.view._needDraw = true;
  416. this.canvasLoading = false;
  417. })
  418. },
  419. // canvas点击事件
  420. canvasClick(item, event) {
  421. console.log(item)
  422. console.log(event)
  423. if (this.type == 4) {//重新划分
  424. } else if (this.type == 5) {//批量
  425. } else {
  426. if (item instanceof SpaceItem && item.selectable) {
  427. if (this.type == 2) {
  428. this.scene.clearZoneSelection();
  429. }
  430. this.type = 3;
  431. this.curZoneItem = {};
  432. }
  433. if (item instanceof ZoneItem && item.selectable) {
  434. if (this.type == 3) {
  435. this.scene.clearSpaceSelection();
  436. }
  437. this.zoneDisable = false;
  438. this.curZoneItem = item;
  439. this.scene.clearZoneSelection();
  440. item.selected = true;
  441. this.$emit('copyID', this.curZoneItem.data.RoomID)
  442. }
  443. }
  444. },
  445. // 编辑平面图
  446. editGraphy() {
  447. this.type = 3;
  448. this.config.isEdit = true;
  449. this.config.groupSelect = false;
  450. this.config.divide = true;
  451. this.scene.isSpaceSelectable = true;
  452. // 设置业务空间不可选
  453. this.scene.isZoneSelectable = false
  454. this.view._needDraw = true;
  455. },
  456. // 查看未关联的业务空间--flag--查看-or-选择
  457. lookUnrelatBSpace(flag) {
  458. this.isAction = flag;
  459. let arr = this.scene.getSelectedSpaces();
  460. if (flag && !arr.length) {
  461. this.$message.warning('请至少选择一个空间');
  462. return;
  463. }
  464. this.$refs.unRelateBSP.showDialog();
  465. },
  466. // 取消(所有取消公用)
  467. cancelGraphy() {
  468. this.init(2);
  469. this.$emit('copyID', '')
  470. },
  471. // 批量创建业务空间弹窗
  472. handleCommand(command) {
  473. this.groupCreateDialogVis = true;
  474. },
  475. // 创建弹窗确认
  476. confirm() {
  477. if (this.groupCreateType == 1) {
  478. this.groupCreateBSpace()
  479. } else if (this.groupCreateType == 2) {
  480. this.type = 5;
  481. this.config.isEdit = true;
  482. this.config.groupSelect = true;
  483. this.config.divide = false;
  484. this.groupCreateDialogVis = false;
  485. // 清空选中空间
  486. this.scene.clearSpaceSelection();
  487. // 设置空间可选
  488. this.scene.isSpaceSelectable = true;
  489. // 设置业务空间不可选
  490. this.scene.isZoneSelectable = false;
  491. }
  492. },
  493. // 根据未关联元空间批量创建业务空间
  494. groupCreateBSpace() {
  495. let text = []
  496. let Spaces = this.allUnRelatISP.map(t => {
  497. if (t.Outline) {
  498. let area = 0;
  499. if (t.Outline[0]) {
  500. area = this.getarea(t.Outline[0]);
  501. if (t.Outline.length > 1) {
  502. for (let i = 1; i < t.Outline.length; i++) {
  503. let temp = this.getarea(t.Outline[i]);
  504. area = area - temp
  505. }
  506. }
  507. area = (area / 1000000).toFixed(2);
  508. if (area < (this.areaValue / 100)) {
  509. return undefined
  510. }
  511. } else {
  512. return undefined;
  513. }
  514. text.push(t.RoomLocalName || t.RoomName)
  515. return {
  516. IspaceId: t.RoomID,
  517. RoomLocalName: t.RoomLocalName || t.RoomName,
  518. Outline: [t.Outline],
  519. BuildingId: this.buildFloor[0],
  520. FloorId: this.buildFloor[1],
  521. Height: t.Height || 0
  522. }
  523. } else {
  524. return undefined
  525. }
  526. }).filter(item => item);
  527. if (Spaces.length) {
  528. this.$confirm(
  529. "<p>确定根据未关联业务空间的空间批量创建业务空间</p>" +
  530. "<p>涉及的空间:</p>" +
  531. "<p style='line-height:20px;max-height:60px;overflow-y:auto;'>" +
  532. text.toString() +
  533. "</p>",
  534. "提示", {
  535. dangerouslyUseHTMLString: true,
  536. confirmButtonText: "确定",
  537. cancelButtonText: "取消",
  538. type: "warning"
  539. }
  540. ).then(() => {
  541. this.groupCreateDialogVis = false;
  542. this.canvasLoading = true;
  543. this.groupCreateBSP(Spaces)
  544. }).catch(() => {
  545. this.$message({
  546. type: "info",
  547. message: "已取消批量创建"
  548. });
  549. });
  550. } else {
  551. this.$message('没有未关联的空间')
  552. }
  553. },
  554. // 创建新的业务空间
  555. createNewZone() {
  556. let arr = this.scene.getSelectedSpaces();
  557. if (arr.length) {
  558. let tempArr = [];
  559. arr.map(t => {
  560. tempArr.push(this.BIMIDToSIName[t.data.SourceId]);
  561. })
  562. this.$refs.createBSP.showDialog(tempArr.toString());
  563. } else {
  564. this.$message.warning('请至少选择一个空间');
  565. }
  566. },
  567. // 根据图创建新的业务空间-弹窗返回确认创建
  568. createRoom(val) {
  569. const zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
  570. let spaces = {};
  571. if (this.scene.cutItem || this.scene.sceneMark) {
  572. // 如果有划分,求交集
  573. // 格式为Poly(先与业务空间求差集)
  574. const obj = this.scene.getZoneDifference(true);
  575. // 差集与楼层平面图或用户划分区域求交集
  576. spaces = this.scene.getPloyIntersect(obj)
  577. } else {
  578. // 格式为SPoint[]
  579. spaces = this.scene.getZoneDifference();
  580. }
  581. for (let key in spaces) {
  582. spaces[key] = spaces[key].map(t => {
  583. let temp = t.map(item => {
  584. return {
  585. X: 1 * item.x.toFixed(2),
  586. Y: -item.y.toFixed(2),
  587. Z: 0
  588. }
  589. })
  590. return temp;
  591. })
  592. let newarr = this.makeMaxAreaFirst(spaces[key])
  593. zoneObj.Outline.push(newarr);
  594. let curISP = this.sourceIdToISP[key];
  595. if (curISP) {
  596. curISP && IspaceIdList.push(curISP.RoomID);
  597. zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
  598. }
  599. }
  600. // 数据计算导致浏览器奔溃,临时注释(测试计算未崩溃改好)
  601. // let zoneObj = { Outline: [], Height: 0 }, IspaceIdList = [];
  602. // let selectSpaces = this.scene.getSelectedSpaces();
  603. // selectSpaces.map(t => {
  604. // zoneObj.Outline.push(t.data.OutLine);
  605. // let key = t.data.SourceId;
  606. // let curISP = this.sourceIdToISP[key];
  607. // if (curISP) {
  608. // IspaceIdList.push(curISP.RoomID);
  609. // zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
  610. // }
  611. // })
  612. // // 如果有划分,求交集
  613. // if (this.scene.cutItem || this.scene.sceneMark) {
  614. // zoneObj.Outline = [];
  615. // let arr = this.scene.getIntersect();
  616. // arr.map(t => {
  617. // let temp = t.map(item => {
  618. // return {
  619. // X: 1 * item.x,
  620. // Y: -item.y,
  621. // Z: 0
  622. // }
  623. // })
  624. // zoneObj.Outline.push([temp]);
  625. // })
  626. // }
  627. // 至此
  628. if (!zoneObj.Outline.length) {
  629. zoneObj.Outline = null;
  630. }
  631. zoneObj.RoomLocalName = val;
  632. zoneObj.BuildingId = this.buildFloor[0];
  633. zoneObj.FloorId = this.buildFloor[1];
  634. this.createSingleBSP(zoneObj, IspaceIdList)
  635. },
  636. // 根据图从未关联平面图的业务空间中选择--按钮返回关联信号
  637. createFromUnrelated(zoneObj) {
  638. zoneObj.Outline = [];
  639. zoneObj.Height = 0;
  640. let spaces = {}, IspaceIdList = [];
  641. if (this.scene.cutItem || this.scene.sceneMark) {
  642. // 如果有划分,求交集
  643. // 格式为Poly(先与业务空间求差集)
  644. const obj = this.scene.getZoneDifference(true);
  645. // 差集与楼层平面图或用户划分区域求交集
  646. spaces = this.scene.getPloyIntersect(obj)
  647. } else {
  648. // 格式为SPoint[]
  649. spaces = this.scene.getZoneDifference();
  650. }
  651. for (let key in spaces) {
  652. spaces[key] = spaces[key].map(t => {
  653. let temp = t.map(item => {
  654. return {
  655. X: 1 * item.x.toFixed(2),
  656. Y: -item.y.toFixed(2),
  657. Z: 0
  658. }
  659. })
  660. return temp;
  661. })
  662. let newarr = this.makeMaxAreaFirst(spaces[key])
  663. zoneObj.Outline.push(newarr);
  664. let curISP = this.sourceIdToISP[key];
  665. if (curISP) {
  666. curISP && IspaceIdList.push(curISP.RoomID);
  667. zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
  668. }
  669. }
  670. // 改回之前逻辑
  671. // zoneObj.Outline = [];
  672. // zoneObj.Height = 0;
  673. // let spaces = {}, IspaceIdList = [];
  674. // let selectSpaces = this.scene.getSelectedSpaces();
  675. // selectSpaces.map(t => {
  676. // zoneObj.Outline.push(t.data.OutLine);
  677. // let key = t.data.SourceId;
  678. // let curISP = this.sourceIdToISP[key];
  679. // if (curISP) {
  680. // curISP && IspaceIdList.push(curISP.RoomID);
  681. // zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
  682. // }
  683. // })
  684. // // 如果有划分,求交集
  685. // if (this.scene.cutItem || this.scene.sceneMark) {
  686. // zoneObj.Outline = [];
  687. // let arr = this.scene.getIntersect();
  688. // arr.map(t => {
  689. // let temp = t.map(item => {
  690. // return {
  691. // X: 1 * item.x,
  692. // Y: -item.y,
  693. // Z: 0
  694. // }
  695. // })
  696. // zoneObj.Outline.push([temp]);
  697. // })
  698. // }
  699. if (!zoneObj.Outline.length) {
  700. zoneObj.Outline = null;
  701. }
  702. this.updateBSPOutline(zoneObj, IspaceIdList)
  703. },
  704. // 编辑空间详情
  705. editeSpaceDetail() {
  706. let item = this.curZoneItem.data;
  707. let query = {
  708. RoomID: item.RoomID,
  709. zone: this.tab.code,
  710. isMyTab: 1,
  711. buildFloorSelectd: this.buildFloor
  712. }
  713. this.$router.push({
  714. path: "/ledger/spaceDetail",
  715. query: query
  716. })
  717. },
  718. // 重新划分业务空间
  719. refactorBSP() {
  720. this.config.isEdit = true;
  721. this.config.groupSelect = false;
  722. this.config.divide = true;
  723. this.type = 4;
  724. // 设置空间可选
  725. this.scene.isSpaceSelectable = true;
  726. // 将已关联的设置不可选,并将当前选的隐藏
  727. this.scene.isZoneSelectable = false;
  728. this.curZoneItem.visible = false;
  729. // 将当前业务空间的每个元素添加到场景中并选中
  730. this.scene.addAllLikeSpace(this.curZoneItem.data.OutLine);
  731. },
  732. // 确认业务空间
  733. confirmZoneSpace() {
  734. let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
  735. let space = {
  736. RoomID: this.curZoneItem.data.RoomID,
  737. State: 0,
  738. ObjectType: ObjectType
  739. }
  740. let pa = {
  741. Content: [space],
  742. Projection: ['State']
  743. }
  744. zoneUpdate(pa, res => {
  745. this.curZoneItem.isInfected = false;
  746. this.$emit('updateState');
  747. this.$message.success('更新成功');
  748. })
  749. },
  750. // 保存并确认业务空间
  751. confirmAndSave() {
  752. this.confirmAndSaveFlag = true;
  753. this.saveRefactorBSP();
  754. },
  755. // 重新划分--保存
  756. saveRefactorBSP() {
  757. let selectSpace = this.scene.getSelectedSpaces();
  758. let selectLikeSpace = this.scene.getSelectedLikeSpace();
  759. //更新业务空间
  760. let zoneObj = { Outline: [], Height: 0, State: this.confirmAndSaveFlag ? 0 : this.curZoneItem.isInfected ? 1 : 0 }, IspaceIdList = [];
  761. // 空间
  762. selectSpace.map(t => {
  763. zoneObj.Outline.push(t.data.OutLine);
  764. if (this.BIMIDToSID[t.data.SourceId]) {
  765. IspaceIdList.push(this.BIMIDToSID[t.data.SourceId]);
  766. }
  767. if (t.Height && (zoneObj.Height == 0 || t.Height < zoneObj.Height)) {
  768. zoneObj.Height = t.Height > 100 ? (t.Height / 1000).toFixed(2) : t.Height;
  769. }
  770. })
  771. // 类空间
  772. selectLikeSpace.map(t => {
  773. zoneObj.Outline.push(t.data);
  774. })
  775. // 如果有划分,求交集
  776. if (this.scene.cutItem || this.scene.sceneMark) {
  777. zoneObj.Outline = [];
  778. let spaceIntersect = this.scene.getIntersect();
  779. spaceIntersect.map(t => {
  780. let temp = t.map(item => {
  781. return {
  782. X: item.x,
  783. Y: -item.y,
  784. Z: 0
  785. }
  786. })
  787. zoneObj.Outline.push([temp]);
  788. })
  789. let likeSpaceIntersect = this.scene.getLikeIntersect();
  790. likeSpaceIntersect.map(t => {
  791. let temp = t.map(item => {
  792. return {
  793. X: item.x,
  794. Y: -item.y,
  795. Z: 0
  796. }
  797. })
  798. zoneObj.Outline.push([temp]);
  799. })
  800. }
  801. if (!zoneObj.Outline.length) {
  802. zoneObj.Outline = null;
  803. }
  804. zoneObj.RoomID = this.curZoneItem.data.RoomID;
  805. this.updateBSPOutline(zoneObj, IspaceIdList)
  806. },
  807. // 根据图批量创建所选业务空间
  808. groupCreateZone() {
  809. let arr = this.scene.getSelectedSpaces();
  810. let createSpaces = [], spaces = {};
  811. if (this.scene.cutItem || this.scene.sceneMark) {
  812. // 如果有划分,求交集
  813. // 格式为Poly(先与业务空间求差集)
  814. const obj = this.scene.getZoneDifference(true);
  815. // 差集与楼层平面图或用户划分区域求交集
  816. spaces = this.scene.getPloyIntersect(obj)
  817. } else {
  818. // 格式为SPoint[]
  819. spaces = this.scene.getZoneDifference();
  820. }
  821. for (let key in spaces) {
  822. let zoneObj = { Outline: [], Height: 0 }
  823. spaces[key] = spaces[key].map(t => {
  824. let temp = t.map(item => {
  825. return {
  826. X: 1 * item.x.toFixed(2),
  827. Y: -item.y.toFixed(2),
  828. Z: 0
  829. }
  830. })
  831. return temp;
  832. })
  833. let newarr = this.makeMaxAreaFirst(spaces[key])
  834. zoneObj.Outline.push(newarr);
  835. if (!zoneObj.Outline.length) {
  836. continue
  837. }
  838. //计算面积
  839. let area = 0, line = zoneObj.Outline;
  840. for (let i = 0; i < line.length; i++) {
  841. for (let j = 0; j < line[i].length; j++) {
  842. if (j == 0) {
  843. area += this.getarea(line[i][0]);
  844. } else {
  845. area -= this.getarea(line[i][j]);
  846. }
  847. }
  848. }
  849. area = (area / 1000000).toFixed(2);
  850. if (area < (this.areaValue / 100)) {
  851. continue
  852. }
  853. //生成空间对象
  854. let curISP = this.sourceIdToISP[key];
  855. if (curISP) {
  856. zoneObj.Height = zoneObj.Height == 0 ? curISP.Height : zoneObj.Height > curISP.Height ? curISP.Height : zoneObj.Height;
  857. zoneObj.IspaceId = curISP.RoomID;
  858. zoneObj.RoomLocalName = curISP.RoomLocalName;
  859. }
  860. zoneObj.BuildingId = this.buildFloor[0];
  861. zoneObj.FloorId = this.buildFloor[1];
  862. createSpaces.push(zoneObj);
  863. }
  864. // 改回之前逻辑
  865. // let arr = this.scene.getSelectedSpaces();
  866. // let createSpaces = [];
  867. // // 如果有划分,求交集
  868. // if (this.scene.cutItem || this.scene.sceneMark) {
  869. // let outlines = this.scene.getIntersectInSpace();
  870. // for (let k in outlines) {
  871. // outlines[k] = outlines[k].map(t => {
  872. // t = t.map(item => {
  873. // item = item.map(j => {
  874. // return { X: j.x, Y: -j.y, Z: 0 }
  875. // })
  876. // return item
  877. // })
  878. // return t;
  879. // })
  880. // }
  881. // createSpaces = arr.map(t => {
  882. // let line = outlines[t.data.SourceId];
  883. // if (!line || !line.length) {
  884. // return undefined
  885. // } else {
  886. // let area = 0;
  887. // for (let i = 0; i < line.length; i++) {
  888. // for (let j = 0; j < line[i].length; j++) {
  889. // if (j == 0) {
  890. // area += this.getarea(line[i][0]);
  891. // } else {
  892. // area -= this.getarea(line[i][j]);
  893. // }
  894. // }
  895. // }
  896. // area = (area / 1000000).toFixed(2);
  897. // if (area < (this.areaValue / 100)) {
  898. // return undefined;
  899. // }
  900. // }
  901. // return {
  902. // IspaceId: this.BIMIDToSID[t.data.SourceId],
  903. // RoomLocalName: this.BIMIDToSIName[t.data.SourceId],
  904. // Outline: line,
  905. // BuildingId: this.buildFloor[0],
  906. // FloorId: this.buildFloor[1],
  907. // Height: t.data.Height > 100 ? (t.data.Height / 1000).toFixed(2) : t.data.Height || 0
  908. // }
  909. // }).filter(item => item)
  910. // } else {
  911. // createSpaces = arr.map(t => {
  912. // let line = t.data.OutLine;
  913. // if (!line || !line.length) {
  914. // return undefined
  915. // } else {
  916. // let area = this.getarea(line[0]);
  917. // if (line.length > 1) {
  918. // for (let i = 1; i < line.length; i++) {
  919. // area -= this.getarea(line[i]);
  920. // }
  921. // }
  922. // area = (area / 1000000).toFixed(2);
  923. // if (area < (this.areaValue / 100)) {
  924. // return undefined;
  925. // }
  926. // }
  927. // return {
  928. // IspaceId: this.BIMIDToSID[t.data.SourceId],
  929. // RoomLocalName: this.BIMIDToSIName[t.data.SourceId],
  930. // Outline: [line],
  931. // BuildingId: this.buildFloor[0],
  932. // FloorId: this.buildFloor[1],
  933. // Height: t.data.Height > 100 ? (t.data.Height / 1000).toFixed(2) : t.data.Height || 0
  934. // }
  935. // }).filter(item => item);
  936. // }
  937. if (createSpaces.length) {
  938. this.canvasLoading = true;
  939. this.groupCreateBSP(createSpaces)
  940. } else {
  941. this.$message.warning('未选择空间');
  942. }
  943. },
  944. // 更新业务空间和元空间的关系
  945. relationInBSPandISP(SpaceId, IspaceIdList) {
  946. let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
  947. let pa = {
  948. data: { SpaceId: SpaceId, IspaceIdList: IspaceIdList },
  949. type: ObjectType
  950. }
  951. createRelateInZoneAndISp(pa, res => {
  952. this.$message.success('创建成功');
  953. this.init(2);
  954. if (this.confirmAndSaveFlag) {
  955. this.confirmAndSaveFlag = false;
  956. this.curZoneItem.selected = false;
  957. this.curZoneItem = {};
  958. this.$emit('updateState');
  959. }
  960. })
  961. },
  962. // 批量更新业务空间和元空间的关系
  963. groupCreRelaZoneAndISp(Spaces) {
  964. Spaces = Spaces.filter(item => item.IspaceId);
  965. let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
  966. if (Spaces.length) {
  967. let param = {
  968. data: {
  969. Content: Spaces
  970. },
  971. type: ObjectType
  972. }
  973. groupCreRelaZoneAndISp(param, res => {
  974. this.$message.success('创建成功')
  975. this.canvasLoading = false;
  976. this.init(2)
  977. })
  978. } else {
  979. this.$message.success('创建成功')
  980. this.canvasLoading = false;
  981. this.init(2)
  982. }
  983. },
  984. // 批量创建
  985. groupCreateBSP(spaces) {
  986. let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
  987. spaces = spaces.map(t => {
  988. t.ObjectType = ObjectType;
  989. t.BIMLocation = this.getAverageVal(t.Outline);
  990. return t;
  991. })
  992. let pa = {
  993. Content: spaces,
  994. }
  995. zoneCreate(pa, res => {
  996. res.EntityList.map(t => {
  997. spaces = spaces.map(item => {
  998. if (t.RoomLocalName == item.RoomLocalName) {
  999. item.SpaceId = t.RoomID
  1000. }
  1001. return item;
  1002. })
  1003. })
  1004. this.groupCreRelaZoneAndISp(spaces)
  1005. })
  1006. },
  1007. // 单个创建
  1008. createSingleBSP(space, IspaceIdList) {
  1009. let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
  1010. space.BIMLocation = space.Outline ? this.getAverageVal(space.Outline) : null;
  1011. space.ObjectType = ObjectType;
  1012. let pa = {
  1013. Content: [space]
  1014. }
  1015. zoneCreate(pa, res => {
  1016. this.relationInBSPandISP(res.EntityList[0].RoomID, IspaceIdList)
  1017. })
  1018. },
  1019. // 更新业务空间区域
  1020. updateBSPOutline(zoneObj, IspaceIdList) {
  1021. let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
  1022. zoneObj.BIMLocation = zoneObj.Outline ? this.getAverageVal(zoneObj.Outline) : null;
  1023. zoneObj.ObjectType = ObjectType;
  1024. zoneObj.BuildingId = this.buildFloor[0];
  1025. zoneObj.FloorId = this.buildFloor[1];
  1026. let pa = {
  1027. Content: [zoneObj],
  1028. Projection: ['BIMLocation', 'ObjectType', 'Outline', 'Height', 'BuildingId', 'FloorId']
  1029. }
  1030. zoneUpdate(pa, res => {
  1031. this.updateZoneBF(zoneObj, IspaceIdList);
  1032. })
  1033. },
  1034. // 从未关联平面图的业务空间中选择时更新业务空间建筑楼层
  1035. updateZoneBF(zoneObj, IspaceIdList) {
  1036. let pa = [{
  1037. Type: zoneObj.ObjectType,
  1038. SpaceId: zoneObj.RoomID,
  1039. Id: zoneObj.FloorId,
  1040. }]
  1041. handleZoneUpdateBd(pa, res => {
  1042. this.relationInBSPandISP(zoneObj.RoomID, IspaceIdList)
  1043. })
  1044. },
  1045. // 查询未关联平面图的业务空间(项目下+当前分区)
  1046. getBSPunrelaISP() {
  1047. let ObjectType = this.tab.code == 'OtherZone' ? this.OtherValue : this.tab.code;
  1048. let pa = {
  1049. Filters: `Outline isNull;ObjectType="${ObjectType}"`
  1050. }
  1051. zoneCount(pa, res => {
  1052. this.num = res.Count;
  1053. })
  1054. },
  1055. // 计算平均值 作为业务空间BIMLocation
  1056. getAverageVal(Outline) {
  1057. let X = 0, Y = 0, Z = 0, len = 0;
  1058. Outline.map(t => {
  1059. if (t[0]) {
  1060. t[0].map(item => {
  1061. X += item.X;
  1062. Y += item.Y;
  1063. Z += item.Z;
  1064. })
  1065. len += t[0].length
  1066. }
  1067. })
  1068. X = (X / len).toFixed(2);
  1069. Y = (Y / len).toFixed(2);
  1070. Z = (Z / len).toFixed(2);
  1071. return `${X},${Y},${Z}`
  1072. },
  1073. // 计算面积
  1074. getarea(arr) {
  1075. if (!arr.length) {
  1076. return 0;
  1077. }
  1078. let sum = 0;
  1079. let n = arr.length;
  1080. arr[n] = arr[0];
  1081. for (let i = 1; i <= n; i++) {
  1082. sum += arr[i].X * arr[i - 1].Y - arr[i - 1].X * arr[i].Y;
  1083. }
  1084. return Math.abs(sum / 2)
  1085. },
  1086. // canvas 获取焦点
  1087. focus() {
  1088. document.getElementById(`floorCanvas`).focus()
  1089. },
  1090. // 清除canvas
  1091. clearGraphy() {
  1092. if (this.view) {
  1093. this.view.scene = null;
  1094. return
  1095. }
  1096. this.view = new FloorView('floorCanvas')
  1097. },
  1098. // 工具栏操作
  1099. // 吸附
  1100. changeAbsorb(isAbsorbing) {
  1101. this.scene.isAbsorbing = isAbsorbing;
  1102. },
  1103. // 框选
  1104. groupSelect() {
  1105. this.scene.isRectSelection = 1;
  1106. },
  1107. // 适配底图到窗口
  1108. fit() {
  1109. if (this.scene.sceneMark) {
  1110. this.view.fitItemToView([this.scene.sceneMark])
  1111. return
  1112. }
  1113. this.view.fitSceneToView()
  1114. },
  1115. // 保存为png
  1116. savePng() {
  1117. this.view.saveImage(`${this.buildFloor[1]}.png`, 'png');
  1118. },
  1119. // 保存为svg
  1120. saveSvg() {
  1121. this.view.saveSceneSvg(`${this.buildFloor[1]}.svg`, 6400, 4800);
  1122. },
  1123. // 保存json
  1124. saveJson() {
  1125. this.view.saveFloorJson(`${this.buildFloor[1]}.json`)
  1126. },
  1127. // 切割划分
  1128. divide() {
  1129. this.scene.isCutting = true;
  1130. },
  1131. // 清除切割划分
  1132. clearDivide() {
  1133. this.scene.clearCut();
  1134. },
  1135. // 撤销
  1136. undo() { },
  1137. // 反撤销
  1138. redo() { },
  1139. // 缩放
  1140. scale(val) {
  1141. if (!this.view) {
  1142. return;
  1143. }
  1144. let scale = this.view.scale;
  1145. this.view.scaleByPoint(val / scale, this.canvasWidth / 2, this.canvasHeight / 2);
  1146. },
  1147. // 给定多个轮廓线的数据,计算得到面积最大值,并把它放置数组第一项
  1148. // list {XYZ}[][]
  1149. makeMaxAreaFirst(list) {
  1150. let arr = [], area = 0;
  1151. for (let i = 0; i < list.length; i++) {
  1152. let temp = this.getarea(list[i])
  1153. if (temp > area) {
  1154. arr.unshift(list[i])
  1155. } else {
  1156. arr.push(list[i])
  1157. }
  1158. }
  1159. return arr;
  1160. }
  1161. },
  1162. filters: {
  1163. cutString: function (str, len) {
  1164. //length属性读出来的汉字长度为1
  1165. if (!!str && typeof str == "string" && str.length > len) {
  1166. return str.substring(0, len) + "...";
  1167. } else {
  1168. return str || "--";
  1169. }
  1170. }
  1171. },
  1172. watch: {
  1173. projectId() {
  1174. this.FloorMap = '';
  1175. this.tab = {};
  1176. },
  1177. "view.scale": {
  1178. handler(n) {
  1179. if (this.$refs.canvasFun) {
  1180. let s = n * 10 / this.view.minScale
  1181. this.$refs.canvasFun.sliderVal = s > 1000 ? 1000 : s;
  1182. }
  1183. }
  1184. },
  1185. "scene.isRectSelection": {
  1186. handler(n) {
  1187. if (!n) {
  1188. this.$refs.canvasFun.active = '';
  1189. }
  1190. }
  1191. },
  1192. "scene.isCutting": {
  1193. handler(n) {
  1194. if (!n) {
  1195. this.$refs.canvasFun.active = '';
  1196. this.$refs.canvasFun.isSwitch = false;
  1197. this.scene.isAbsorbing = false;
  1198. }
  1199. }
  1200. },
  1201. }
  1202. }
  1203. </script>
  1204. <style lang="less" scoped>
  1205. #graphy {
  1206. position: relative;
  1207. width: 100%;
  1208. box-sizing: border-box;
  1209. padding: 0 10px 10px;
  1210. height: calc(100% - 56px);
  1211. .canvas-box {
  1212. width: 100%;
  1213. height: 100%;
  1214. }
  1215. .buttons-box {
  1216. position: absolute;
  1217. top: 0;
  1218. left: 0;
  1219. padding: 0 10px;
  1220. width: 100%;
  1221. z-index: 999;
  1222. & > div {
  1223. float: left;
  1224. }
  1225. /deep/ .el-autocomplete {
  1226. display: inline-block;
  1227. width: 320px;
  1228. margin-right: 10px;
  1229. }
  1230. .button-group button,
  1231. .button-group .el-dropdown {
  1232. display: block;
  1233. float: left;
  1234. }
  1235. .my-autocomplete {
  1236. li {
  1237. line-height: normal;
  1238. padding: 7px;
  1239. .name {
  1240. text-overflow: ellipsis;
  1241. overflow: hidden;
  1242. }
  1243. .addr {
  1244. font-size: 12px;
  1245. color: #b4b4b4;
  1246. }
  1247. .highlighted .addr {
  1248. color: #ddd;
  1249. }
  1250. }
  1251. }
  1252. }
  1253. .canvas-actions-box {
  1254. position: absolute;
  1255. bottom: 60px;
  1256. left: 50%;
  1257. transform: translateX(-50%);
  1258. z-index: 99;
  1259. }
  1260. #autoRelate {
  1261. /deep/ .el-slider__marks-text:nth-child(2) {
  1262. width: 25px;
  1263. }
  1264. }
  1265. }
  1266. </style>