1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312 |
- <template>
- <div ref="graphyMain" class="canvasGraphy" style="width:100%;" v-loading="loading.show" :element-loading-text="loading.num + '/' + loading.total">
- <div v-show="hasMap" class="header-search">
- <!-- 初始两个按钮 -->
- <div v-show="type == 1">
- <el-button @click=" type = 2" icon="el-icon-search">查找业务空间</el-button>
- <el-button @click="myDialogVisible = true">创建业务空间</el-button>
- <span style="font-size:13px;color:#606266;margin-left:40px;display:inline-block;">
- 提示:
- <i style="color:red;">红色字体</i>的业务空间为不相邻元空间组成,请检查是否要修改
- </span>
- </div>
- <!-- 搜索下拉列表定位 -->
- <div v-show="type == 2">
- <el-autocomplete popper-class="my-autocomplete" v-model="search" :fetch-suggestions="querySearch" placeholder="输入平面图中已有的业务空间名称进行查找" width="180px" @select="handleSelect">
- <i class="el-icon-search el-input__icon" slot="suffix" @click="handleIconClick"></i>
- <template slot-scope="{ item }">
- <div class="name" style="position: relative;">
- {{ item.infos.RoomLocalName |cutString(8) }}
- <span
- class="addr"
- style="position: absolute;right:10px;color:#409EFF;"
- >定位</span>
- </div>
- </template>
- </el-autocomplete>
- <el-button style="margin-left:10px;" type="text" @click="clearDimension">收起</el-button>
- </div>
- <!-- 点击元空间显示 -->
- <div v-show="type == 3">
- <div class="div50">
- <el-button
- class="float-right"
-
- @click="SpaceDialog"
- type="primary"
- plain
- >从未关联元空间的业务空间中选择</el-button>
- </div>
- <div class="div50">
- <el-button @click="clearDimension" plain>取 消</el-button>
- <el-button @click="createSP" type="primary">创建新的业务空间</el-button>
- </div>
- </div>
- <!-- 点击业务空间显示 -->
- <div v-show="type == 4">
- <div class="div50">
- <el-button class="float-right" @click="divide" type="primary" plain>重新划分业务空间</el-button>
- </div>
- <div class="div50">
- <el-button @click="clearDimension" plain>取 消</el-button>
- <el-button @click="bussinDea" type="primary">查看详情</el-button>
- </div>
- </div>
- <!-- 点击业务空间后点击元空间 -->
- <div v-show="type == 5">
- <div class="div50">
- <el-button @click="clearDimension" class="float-right" plain>取 消</el-button>
- </div>
- <div class="div50">
- <el-button @click="saveChange" type="primary">保存修改</el-button>
- </div>
- </div>
- <el-button
- v-show="type == 1"
- @click="getPiss"
- style="position: absolute;top: 10px;right: 10px;"
-
- type="text"
- >未关联元空间的业务空间 {{num}} 条</el-button>
- </div>
- <div
- v-show="hasMap"
- ref="canvasWidth"
- class="canvasWidth"
- v-loading="myLoading"
- style="width:100%;"
- >
- <canvas :id="canvasId + 'canvas' " :width="canvasW" :height="canvasH"></canvas>
- <div
- style="height: 35px;overflow: hidden;z-index:99;transform: translateX(-50%);position: absolute;bottom: 10%;left: 50%;"
- >
- <el-button @click="smallSize" type="primary">- 缩小</el-button>
- <el-button @click="suitableSize" type="primary">合适比例</el-button>
- <el-button @click="bigSize" type="primary">+ 放大</el-button>
- </div>
- </div>
- <div
- v-show="!hasMap"
- class="center"
- style="height: 400px;padding-top:200px;box-sizing:border-box;"
- >
- <i class="iconwushuju iconfont"></i>
- {{!!buildMess ? '请初始化平面图' : '请选择楼层'}}
- </div>
- <el-dialog title="提示" :visible.sync="dialogVisible" :before-close="clearDimension" width="30%">
- <p style="color:red;line-height:24px;margin-bottom: 10px;" v-show="isAbutMsg">注意:您选择的元空间并未相邻!</p>
- <p style="line-height:24px;margin-bottom: 10px;">请输入创建的业务空间名:</p>
- <!-- <p>
- <el-input
- placeholder="请输入业务空间名"
- v-model="name"
-
- clearable>
- </el-input>
- </p>-->
- <el-form
- :model="ruleForm"
- :rules="rules"
- ref="ruleForm"
- label-width="100px"
- class="demo-ruleForm"
- >
- <el-form-item label label-width="0" prop="name">
- <el-input v-model="ruleForm.name"></el-input>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="clearDimension">取 消</el-button>
- <el-button type="primary" @click="isTrue">确 定</el-button>
- </span>
- </el-dialog>
- <el-dialog title="提示" :visible.sync="myDialogVisible" width="30%">
- <p style="line-height:26px;">方法1:直接在平面图中点击单个或多个带⬇️标记的元空间创建业务空间</p>
- <p style="line-height:26px;">方法2:根据未关联业务空间的元空间批量创建业务空间</p>
- <span slot="footer" class="dialog-footer">
- <el-button @click="createBatchSq">批量创建业务空间</el-button>
- <el-button type="primary" @click="myDialogVisible = false">返回平面图手动选择</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import axios from "axios";
-
- import {
- SGraphyView,
- SGraphyScene,
- SGraphyRectItem,
- SGraphyLineItem,
- SGraphyPolygonItem,
- SGraphyVirtualItem,
- SGraphyImageItem,
- SGraphyPillarItems
- } from "@/assets/graphy";
- import pako from '@/assets/pako/pako'
-
- import tools from "@/utils/scan/tools";
- let data = "";
- let scale = 120;
- let myData = [{
- Id: "1221512",
- PointList: {
- X: -35146.875,
- Y: 40680
- }
- }];
-
-
-
-
-
-
-
-
-
-
-
-
- let colorArr = [
- "#F9C3C3",
- "#FFD1BF",
- "#FFF3BF",
- "#D8F7C6",
- "#C6F2F6",
- "#DCE3C0",
- "#FAE6C9",
- "#E3D7F7",
- "#C4CBF8",
- "#DEC3F6"
- ];
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- class MainScene extends SGraphyScene {
- constructor() {
- super();
-
- }
-
-
- }
- import {
- formBIMToPri,
- createBusiness,
- createRelation,
- getGraphyId,
- getBussines2,
- getRelation,
- deleteRelation,
- isAbut
- } from "@/api/scan/request";
- import {mapGetters, mapActions} from "vuex";
- export default {
- name: "HelloWorld",
- props: {
- canvasId: {
- type: String
- }
- },
- computed: {
- ...mapGetters("layout", [
- "projectId",
- "secret",
- "userId"
- ])
- },
- data() {
- return {
- view: "",
- num: "",
- mainScene: new MainScene(),
- dataMax: "",
- scene: {
- x: 0,
- y: 0
- },
- dialogVisible: false,
- id: null,
- canvasH: 600,
- canvasW: 800,
- param: {
- ProjId: "",
- UserId: "",
- secret: ""
- },
- myDialogVisible: false,
- wallList: [],
- type: 1,
- restaurants: [],
- search: "",
- idList: [],
- buildMess: null,
- loading: {
- show: false,
- num: 0,
- total: 0,
- errorNum: 0
- },
- graphyId: "",
- relationList: [],
- myLoading: false,
- hasMap: false,
- ruleForm: {
- name: ""
- },
- rules: {
- name: [{
- required: true,
- message: "请输入需要创建的业务空间名称",
- trigger: "blur"
- }]
- },
- isAbutMsg: false,
- businessData: "",
- spaceType: {},
- };
- },
- created() {
- this.param.ProjId = this.projectId
- this.param.secret = this.secret
- this.param.UserId = this.userId
-
-
- },
- mounted() {
- console.log(this.canvasId)
-
-
- },
- methods: {
-
- getData(floorMap, buildMess, data) {
- this.spaceType = data
- this.loading.show = false;
- this.type = 1;
- this.idList = [];
- this.buildMess = buildMess;
- if (!floorMap) {
- this.hasMap = false;
- } else {
- this.getJson(floorMap);
- this.hasMap = true;
- }
- },
- clearList() {
- this.idList = []
- },
-
- getPiss() {
- this.$emit("getSp", [{}], this.buildMess, this.graphyId);
- },
-
- getHasSpace() {
- console.log(this.spaceType, "spaceType")
- let param = {
- data: {
- criteria: {
- id: this.buildMess.code,
-
-
-
-
- type: [this.spaceType.code],
- "include": [
- {
- "graphId": this.graphyId,
- "graphType": this.spaceType.code,
- "relType": this.spaceType.rel_type,
- "side": "toId",
-
-
- }
- ]
- },
- },
- ProjId: this.param.ProjId,
- secret: this.param.secret
- }
- getBussines2(param)
- .then(res => {
- if (res.data.Result == "success") {
- this.restaurants = res.data.Content;
- let nameList = [];
- if (res.data.Content && res.data.Content.length) {
- this.relationList = res.data.Content.map(item => {
- nameList.push(item.infos.RoomLocalName);
- return item.id;
- });
- this.locationPath(this.relationList, nameList);
- }
- } else {
- this.$message.error(res.data.ResultMsg);
- }
- this.myLoading = false;
- })
- .catch(() => {
-
- });
- },
-
- isTrue() {
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- this.loading.show = true;
- this.loading.num = 0;
- this.loading.total = 1 * 2;
- this.businessData.infos.RoomLocalName[0].value = this.ruleForm.name;
- this.createSpace(this.businessData, this.idList, true);
- this.dialogVisible = false;
- } else {
-
- return false;
- }
- });
- },
-
- getNoSpace() {
- getBussines2({
- data: {
- criteria: {
- id: this.buildMess.code,
-
-
-
-
- type: [this.spaceType.code],
- "exclude": [
- {
- "graphId": this.graphyId,
- "graphType": this.spaceType.code,
- "relType": this.spaceType.rel_type,
- "side": "toId",
-
-
- }
- ]
- },
- },
- ProjId: this.projectId,
- secret: this.secret
- })
- .then(res => {
- if (res.data.Result == "success") {
- this.num = res.data.Content.length;
- } else {
- this.$message.error(res.data.ResultMsg);
- }
- })
- .catch(() => {
-
- });
- },
-
- typeTo1() {
- if (this.type == 2) {
- this.type = 1;
- }
- },
- getJson(jsonId) {
- axios({
- method: 'get',
- url: "/image-service/common/file_get/" + jsonId + "?systemId=revit",
- data: {},
- responseType: 'blob',
-
- })
- .then(res => {
-
- let data = null
- var blob = res.data;
- var reader = new FileReader();
- reader.readAsBinaryString(blob)
-
- let _this = this
- reader.onload = function(readerEvt) {
-
- var binaryString = readerEvt.target.result;
-
-
- let base64Data = btoa(binaryString)
- let unGzipData = pako.unzip(base64Data)
-
-
- data = unGzipData
- _this.dataMax = tools.getPoint(data);
- console.log(unGzipData, data)
- if (data.WallList && data.WallList.length) {
- tools.changeMap(data.WallList, -1, "PointList");
- }
- if (data.SpaceList && data.SpaceList.length) {
- tools.changeMap(data.SpaceList, -1, "Paths");
- }
- if (data.ColumnList && data.ColumnList.length) {
- tools.changeMap(data.ColumnList, -1, "Path");
- }
- if (data.VirtualWallList && data.VirtualWallList.length) {
- tools.changeMap(data.VirtualWallList, -1, "PointList");
- }
- if (data.EquipmentList && data.EquipmentList.length) {
- tools.changeMap(data.EquipmentList, -1, "PointList");
- }
- let ids = [];
- if (data.SpaceList && data.SpaceList.length) {
- data.SpaceList.map(items => {
- items.BimId = _this.buildMess.code + ":" + items.BimId;
- ids.push(items.BimId);
- });
- } else {
- _this.$message("没有元空间数据")
- }
- console.log(ids,'ids')
- if(!!ids && ids.length){
- _this.bimIdToId(ids, data);
- }else{
-
- _this.hasMap = false
- }
- _this.myLoading = true;
- };
-
- });
- },
-
- getGraphy() {
- getGraphyId({
- type: "ElementSptoSpace",
- ProjId: this.projectId,
- secret: this.secret
- })
- .then(res => {
- if (res.data.Result == "success") {
- this.graphyId = res.data.graph_id;
- this.getHasSpace();
- this.getNoSpace();
- } else {
- this.$message.error(res.data.ResultMsg);
- }
- })
- .catch(() => {
- this.$message.error("请求错误");
- });
- },
- bimIdToId(ids, data) {
- formBIMToPri({
- type: ["Si"],
- ids: ids,
- ProjId: this.param.ProjId,
- secret: this.param.secret
- })
- .then(res => {
- if (res.data.Result == "success") {
- data.SpaceList.map((item, index) => {
- res.data.Content.map((i, li) => {
-
- if (item.BimId == i.infos.BIMID) {
- item.id = i.id;
- }
- });
- });
- this.createCanvas();
- this.initGraphy(data);
- console.log("请求完毕")
- } else {
- this.$message.error(res.data.ResultMsg);
- }
- })
- .catch(() => {
- this.$message.error("请求出错");
- });
- },
-
- createCanvas() {
-
- if (this.view.scene) {
- this.view.scene.root.children = [];
- this.view = null;
- }
- this.view = new SGraphyView(this.canvasId + "canvas", this.mainScene);
- this.view.onDraw();
-
-
- },
-
- resetSize() {
- this.canvasW =
- document.getElementById("businessSpace").offsetWidth - 2;
- this.canvasH = document.getElementById("app").offsetHeight - 210;
- let classs = document.getElementsByClassName("canvasWidth");
-
-
-
- this.$refs.canvasWidth.style.height = this.canvasH + "px";
- },
-
- initGraphy(data) {
- this.resetSize();
- this.view.pos.x = this.view.pos.y = -50;
- let equip = data.EquipmentList,
- wall = data.WallList,
- virtual = data.VirtualWallList,
- space = data.SpaceList,
- column = data.ColumnList,
- spaceStr;
-
- if (space && space.length) {
- for (let i = 0; i < space.length; i++) {
- if (space[i].Paths[1] && space[i].Paths[1].length >= 2) {
- spaceStr = new SGraphyPolygonItem(
- space[i].Paths[0],
- 1,
- "rgba(111,111,111,0.5)",
- "#fff",
- space[i].id, {
- x: space[i].LocationPoint.X,
- y: space[i].LocationPoint.Y * -1
- },
- space[i].Name,
- space[i].Paths
- );
- this.mainScene.addItem(spaceStr);
- }
- }
- for (let i = 0; i < space.length; i++) {
- if (space[i].Paths[0] && space[i].Paths[0].length >= 2 && !!!space[i].Paths[1]) {
- spaceStr = new SGraphyPolygonItem(
- space[i].Paths[0],
- 1,
- "rgba(111,111,111,0.5)",
- "#fff",
- space[i].id, {
- x: space[i].LocationPoint.X,
- y: space[i].LocationPoint.Y * -1
- },
- space[i].Name
- );
- this.mainScene.addItem(spaceStr);
- }
- }
- }
-
- let rect = this.view.scene.worldRect();
-
- this.view.scale = 1;
-
- this.view.scale = Math.min(
- this.view.width / (rect.width * 1.2),
- this.view.height / (rect.height * 1.2)
- );
- this.view.minScale = this.view.scale / 10
- this.view.maxScale = this.view.scale * 10
-
- this.view.pos.x =
- (-(rect.right + rect.left) / 2) * this.view.scale + this.view.width / 2;
- this.view.pos.y =
- (-(rect.bottom + rect.top) / 2) * this.view.scale +
- this.view.height / 2;
-
- this.view.canvasView.addEventListener("click", this.checkSpace);
- this.getGraphy();
- },
-
-
- checkSpace(e) {
- let item = tools.mouseInElement(this.view, e);
- console.log(item)
- let items = this.mainScene.root.children;
-
- if (
- item.falg &&
- item.item.businessId &&
- (item.item.isBusiness == 2 || item.item.isBusiness == 7)
- ) {
-
- if (this.type == 2) {
- this.idList = [];
- items.map(i => {
- if (i.isBusiness == 3) {
- i.isBusiness = 2;
- }
- });
- }
- items.map(i => {
- if (i.isBusiness == 6) {
- i.isBusiness = 2;
- } else if (i.isBusiness == 3) {
- i.isBusiness = 1;
- }
- });
- this.type = 4;
- items.map(i => {
- if (i.isBusiness == 6) {
- i.isBusiness = 2;
- }
- if (i.businessId == item.item.businessId) {
- i.isBusiness = 6;
- }
- });
- this.idList.push({
- id: item.item.businessId,
- name: item.item.businessName || item.item.name
- });
- }
-
- if (
- item.falg &&
- !item.item.businessId &&
- (item.item.isBusiness == 4 || item.item.isBusiness == 1) &&
- this.type != 5
- ) {
-
- if (this.type == 4) {
- this.idList = [];
- items.map(i => {
- if (i.isBusiness == 6) {
- i.isBusiness = 2;
- } else if (i.isBusiness == 3) {
- i.isBusiness = 1;
- }
- });
-
- }
- this.type = 3;
- item.item.isBusiness = 3;
- this.idList.push({
- id: item.item.id,
- name: item.item.businessName || item.item.name
- });
- }
-
- if (
- this.type == 5 &&
- item.falg &&
- !item.item.businessId &&
- (item.item.isBusiness == 4 || item.item.isBusiness == 1)
- ) {
- item.item.isBusiness = 3;
- this.idList.push({
- id: item.item.id,
- name: item.item.businessName || item.item.name
- });
- }
-
- if (
- item.falg &&
- item.item.businessId &&
- (item.item.isBusiness == 4 || item.item.isBusiness == 1)
- ) {
-
- item.item.isBusiness = 3;
- this.idList.push({
- id: item.item.id,
- name: item.item.businessName || item.item.name,
- parentId: item.item.businessId
- });
- }
- if (item.falg && item.item.isBusiness == 5) {
- this.$message("该空间为业务空间,请勿点击");
- }
-
- },
-
- querySearch(queryString, cb) {
- var restaurants = this.restaurants;
- var results = queryString ?
- restaurants.filter(this.createFilter(queryString)) :
- restaurants;
-
- cb(results);
- },
- createFilter(queryString) {
- return restaurant => {
- return restaurant.infos.RoomLocalName.indexOf(queryString) > -1;
- };
- },
- handleSelect(item) {
- this.locationPath(item.id);
- },
- handleIconClick(ev) {
- this.locationPath(ev.id);
- },
-
- locationPath(id, name) {
- let param = {
- criterias: {},
- ProjId: this.projectId,
- secret: this.secret
- },
- falg = false;
-
- if (id instanceof Array) {
- falg = true;
- param.criterias.criterias = [];
- id.map(item => {
- param.criterias.criterias.push({
- to_id: item,
- graph_id: this.graphyId,
- rel_type: this.spaceType.rel_type
- });
- });
- } else {
-
- param.criterias.criteria = {
- to_id: id,
- graph_id: this.graphyId,
- rel_type: this.spaceType.rel_type
- };
- }
- getRelation(param)
- .then(res => {
- if (res.data.Result == "success") {
- if (falg) {
-
- this.relationList = [];
- id.map((item, index) => {
- let children = res.data.Content[index].Content.map(i => {
- if (!!i) {
- return i.from_id;
- } else {
- return undefined;
- }
- });
- this.relationList.push({
- id: item,
- name: name[index],
- children: children,
- isAdjacent: true
- });
- });
- this.relationList.reverse();
-
-
- this.spaceIsAbut(this.relationList);
- } else {
-
- this.getPathToCanvas(res.data.Content[0].from_id);
- }
- } else {
- this.$message.error(res.data.ResultMsg);
- }
- })
- .catch(() => {
- this.$message.error("请求错误");
- });
- },
-
- getColor(list) {
- let items = this.mainScene.root.children;
- list.map(item => {
- if (item.children && item.children.length) {
- item.children.map(space => {
- items.map(canvas => {
- if (canvas.id == space) {
- canvas.businessId = item.id;
- canvas.businessName = item.name;
- }
- });
- });
- }
- });
- this.applyColor(list);
- },
-
- applyColor(list) {
- let items = this.mainScene.root.children;
- items.map(item => {
- item.businessId = null;
- item.businessName = null;
- item.businessColor = "rgba(0,0,0,0)";
- item.isBusiness = 1;
- });
- list.map((item, index) => {
- if (item.children && item.children.length) {
- item.children.map(space => {
- items.map(canvas => {
- if (canvas.id == space) {
- canvas.businessId = item.id;
- canvas.businessName = item.name;
- canvas.businessColor = colorArr[index % 10];
- canvas.isBusiness = 2;
-
- if (!item.isAbut) {
- canvas.isBusiness = 7;
- }
- }
- });
- });
- }
- });
- },
- spaceIsAbut(list) {
- let data = list.map(item => {
- return {
- ids: item.children
- };
- });
- let param = {
- data: {
- floor: this.buildMess.code,
- criterias: data
- },
- ProjId: this.projectId,
- secret: this.secret
- };
-
- isAbut(param)
- .then(res => {
- if (res.data.Result == "success") {
- res.data.Content.map((item, index) => {
- this.relationList[index].isAbut = item.abut;
- });
- this.getColor(this.relationList);
- } else {
- this.$message.error(res.data.ResultMsg);
- }
- })
- .catch(() => {
- this.$message.error("请求出错");
- });
- },
- getPathToCanvas(id) {
- let items = this.mainScene.root.children;
- items.map(item => {
- if (item.id == id) {
-
- this.view.pos.x = -item.centerOfGravityPoint.x * this.view.scale +
- this.view.width / 2;
- this.view.pos.y = -item.centerOfGravityPoint.y * this.view.scale +
- this.view.height / 2;
- this.view.scale = this.view.scale;
- item.isBusiness = 3;
- this.idList = [];
- console.log(item)
- this.idList.push({
- id: item.businessId,
- name: item.businessName || '--'
- });
- } else if (item.businessId) {
- item.isBusiness = 2;
- } else {
- item.isBusiness = 1;
- }
- });
- },
-
- SpaceDialog() {
- this.$emit("dimension", this.idList, this.buildMess, this.graphyId);
- },
- bussinDea() {
- this.$emit("businessDetails", this.idList[this.idList.length - 1]);
- },
-
- saveChange() {
- let id = ""
- this.idList.map(item => {
- if (!!item.parentId) {
- id = item.parentId
- }
- })
- this.deleteRela(id);
- },
-
- suitableSize() {
-
- let rect = this.view.scene.worldRect();
-
- this.view.scale = Math.min(
- this.view.width / (rect.width * 1.2),
- this.view.height / (rect.height * 1.2)
- );
-
- this.view.pos.x =
- (-(rect.right + rect.left) / 2) * this.view.scale + this.view.width / 2;
- this.view.pos.y =
- (-(rect.bottom + rect.top) / 2) * this.view.scale +
- this.view.height / 2;
- },
-
- smallSize() {
-
- let rect = this.view.scene.worldRect();
-
- this.view.scale = this.view.scale * 0.9;
-
- this.view.pos.x =
- (-(rect.right + rect.left) / 2) * this.view.scale + this.view.width / 2;
- this.view.pos.y =
- (-(rect.bottom + rect.top) / 2) * this.view.scale +
- this.view.height / 2;
- },
- bigSize() {
-
- let rect = this.view.scene.worldRect();
-
- this.view.scale = this.view.scale * 1.1;
-
- this.view.pos.x =
- (-(rect.right + rect.left) / 2) * this.view.scale + this.view.width / 2;
- this.view.pos.y =
- (-(rect.bottom + rect.top) / 2) * this.view.scale +
- this.view.height / 2;
- },
-
- deleteRela(id) {
- let param = {
- data: {
- criterias: [{
- to_id: id,
- graph_id: this.graphyId,
- rel_type: this.spaceType.rel_type
- }]
- },
- ProjId: this.projectId,
- secret: this.secret
- };
- if (id) {
- deleteRelation(param)
- .then(res => {
- if (res.data.Result == "success") {
- this.loading.show = true;
- this.loading.num = 0;
- this.loading.total = 1;
- this.addRelation(id, this.idList);
- } else {
- this.$message.error(res.data.ResultMsg);
- }
- })
- .catch(() => {
- this.$message.error("请求失败");
- });
- } else {
- this.$message.error("请选择包含原业务空间的区域块")
- }
- },
-
- clearDimension() {
- this.myLoading = true;
- let indexs = tools.clear(
- this.mainScene.root.children,
- 3,
- this.idList,
- "id"
- );
- this.myDialogVisible = false;
- this.dialogVisible = false;
- for (let i = 0; i < indexs.length; i++) {
- this.mainScene.root.children[indexs[i]].isBusiness = 1;
- }
- this.idList = [];
- this.type = 1;
- this.getHasSpace();
- },
-
- createSP() {
- let businessData = {
- building_id: this.buildMess.buildCode,
- floor_id: this.buildMess.code,
- business_type: this.spaceType.code,
- infos: {
- RoomLocalName: [{
- value: tools.getText(this.idList, "name")
- }]
- }
- };
- let data = [];
- this.idList.map(i => {
- data.push(i.id);
- });
- let param = {
- data: {
- floor: this.buildMess.code,
- criterias: [{
- ids: data
- }]
- },
- ProjId: this.projectId,
- secret: this.secret
- };
-
-
- isAbut(param)
- .then(res => {
- if (res.data.Result == "success") {
- this.dialogVisible = true;
- this.ruleForm.name = businessData.infos.RoomLocalName[0].value;
- this.businessData = businessData;
- if (res.data.Content[0].abut) {
- this.isAbutMsg = false;
-
- } else {
- this.isAbutMsg = true;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- } else {
- this.$message.error(res.data.ResultMsg);
- }
- })
- .catch(() => {
- this.$message.error("请求失败");
- });
- },
-
- compareSpace(ids) {
-
- },
-
- divide() {
- this.type = 5;
- let id = this.idList[this.idList.length - 1],
- items = this.mainScene.root.children;
- items.map(item => {
- if (item.businessId == id.id) {
- item.isBusiness = 4;
- } else if (item.businessId) {
- item.isBusiness = 5;
- }
- });
- this.idList = [];
- },
-
- createBatchSq() {
- let items = this.mainScene.root.children;
- let map = [];
- items.map(item => {
- if (!item.businessId) {
- map.push({
- id: item.id,
- name: item.name
- });
- }
- });
- let text = tools.getText(map, "name");
- this.$confirm(
-
-
-
- "<p>确定根据未关联业务空间的元空间批量创建业务空间</p>" +
- "<p>涉及的元空间:</p>" +
- "<p style='line-height:20px;max-height:60px;overflow-y:auto;'>" +
- text +
- "</p>",
-
- "提示", {
- dangerouslyUseHTMLString: true,
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }
- )
- .then(() => {
- this.loading.show = true;
- this.loading.num = 0;
- this.loading.total = map.length * 2;
- this.myDialogVisible = false;
- map.map(item => {
- this.createSpace({
- building_id: this.buildMess.buildCode,
- floor_id: this.buildMess.code,
- business_type: this.spaceType.code,
- infos: {
- RoomLocalName: [{
- value: item.name
- }]
- }
- },
- item.id,
- true
- );
- });
- })
- .catch(() => {
- this.$message({
- type: "info",
- message: "已取消批量创建"
- });
- });
- },
-
- createSpace(data, id, falg) {
- let param = {
- ProjId: this.projectId,
- secret: this.secret,
- data: data
- };
- createBusiness(param).then(res => {
- if (res.data.Result == "success") {
- if (falg) {
- this.loading.num++;
- this.addRelation(res.data.id, id);
- } else {}
- } else {
- this.loading.num++;
- this.$message.error("修改发生错误:" + res.data.ResultMsg);
- }
- });
- },
-
- addRelation(SpId, SiId) {
- let data = {};
- if (SiId instanceof Array) {
- data.criterias = [];
- SiId.map(item => {
- data.criterias.push({
- from_id: item.id,
- to_id: SpId,
- graph_id: this.graphyId,
- rel_type: this.spaceType.rel_type
- });
- });
- } else {
- data = {
- from_id: SiId,
- to_id: SpId,
- graph_id: this.graphyId,
- rel_type: this.spaceType.rel_type
- };
- }
- createRelation({
- data: data,
- ProjId: this.projectId,
- secret: this.secret
- })
- .then(res => {
- if (res.data.Result == "success") {
- this.loading.num++;
- if (this.loading.num == this.loading.total) {
- this.loading.show = false;
- this.getHasSpace();
- this.idList = [];
- this.$message.success("添加成功");
- this.type = 1;
- }
- } else {
- this.$message.error(res.data.ResultMsg);
- this.loading.errorNum++;
- }
- })
- .catch(() => {
- this.$message.error("请求出错");
- this.loading.errorNum++;
- });
- }
- },
- filters: {
- cutString: function(str, len) {
-
- if (!!str && typeof str == "string" && str.length > len) {
- return str.substring(0, len) + "...";
- } else {
- return str || "--";
- }
- }
- },
- watch: {
- projectId(){
- this.buildMess = null
- this.param.ProjId = this.projectId
- this.param.secret = this.secret
- this.param.UserId = this.userId
- this.hasMap = false
- }
- }
- };
- </script>
- <!-- Add "scoped" attribute to limit CSS to this component only -->
- <style lang="less">
- .canvasGraphy {
- position: relative;
- canvas {
- border: 1px solid #ccc;
- }
- .header-search {
- position: absolute;
- top: 0;
- height: 50px;
- line-height: 50px;
- padding-left: 20px;
- background-color: rgba(205, 197, 191, 0.4);
- left: 0;
- right: 0;
- top: 0;
- z-index: 99;
- >div {
- height: 50px;
- }
- .div50 {
- float: left;
- width: 50%;
- height: 100%;
- .float-right {
- float: right;
- margin-top: 11px;
- margin-right: 10%;
- }
- }
- }
- .el-autocomplete {
- width: 320px;
- }
- .my-autocomplete {
- li {
- line-height: normal;
- padding: 7px;
- .name {
- text-overflow: ellipsis;
- overflow: hidden;
- }
- .addr {
- font-size: 12px;
- color: #b4b4b4;
- }
- .highlighted .addr {
- color: #ddd;
- }
- }
- }
- }
- </style>
|