<template>
  <div id="divGraphEdit" v-loading.fullscreen.lock="fullscreenLoading">
    <div class="firstRow">
      <div class="firstOperDivContainer">
        <img
          class="imgBar"
          src="../../assets/images/systemGraph/editLogo.svg"
        />
        <span class="headerTitle">系统图编辑器</span>
        <div class="operBtnDiv" v-if="operState === 0">
          <span>回到首页</span>
          <span>编辑系统图</span>
          <span>上架系统图</span>
          <span>下架系统图</span>
        </div>
        <div class="operBtnDiv" v-if="operState === 1">
          <span>保存图纸</span>
          <span>放弃编辑</span>
        </div>
        <span class="delBtn">删除图纸</span>
      </div>
      <div class="secondOperDivContainer">
        <img
          class="imgBar"
          src="../../assets/images/systemGraph/barController.svg"
        />
        <span class="el-icon-caret-bottom sanjiaoBar"></span>
        <hr class="splitLine" />
        <el-select v-model="selectScale" value-key="value">
          <el-option
            v-for="item in scaleArr"
            :key="item.value"
            :label="item.name"
            :value="item"
          >
          </el-option>
        </el-select>
        <span class="el-icon-zoom-in zoomin"></span>
        <span class="el-icon-zoom-out zoomout"></span>
        <hr class="splitLine" v-if="operState == 1" />
        <img
          v-if="operState == 1"
          class="imgLeftTop"
          src="../../assets/images/systemGraph/leftTop.svg"
        />
        <img
          v-if="operState == 1"
          class="rightLeftTop"
          src="../../assets/images/systemGraph/rightTop.svg"
        />
        <hr class="splitLine" v-if="operState == 1" />
        <img
          v-if="operState == 1"
          class="imgLeftTop"
          src="../../assets/images/systemGraph/text.svg"
        />
        <span class="resetBtn" v-if="operState == 1">重置为自动出图样式</span>
      </div>
    </div>
    <div class="secondRow">
      <div class="graphInfoContainer" v-if="operState === 0 || operState === 1">
        <div class="graphInfoFirst">
          <span class="graphInfoName">系统图名称</span>
          <span class="graphInfoFirstEdit">编辑</span>
        </div>
        <div class="graphInfoContent">
          <span>高压系统1#系统图</span>
        </div>

        <div class="graphInfoName">
          <span>系统图类型</span>
        </div>
        <div class="graphInfoContent">
          <span>高压配电</span>
        </div>

        <div class="graphInfoName">
          <span>系统实例</span>
        </div>
        <div class="graphInfoContent">
          <span>实例1</span>
        </div>

        <div class="graphInfoName">
          <span>系统图模版</span>
        </div>
        <div class="graphInfoContent">
          <span>模版1</span>
        </div>

        <div class="graphInfoName">
          <span>所属项目</span>
        </div>
        <div class="graphInfoContent">
          <span>银泰中心</span>
        </div>

        <div class="graphInfoName">
          <span>当前状态</span>
        </div>
        <div class="graphInfoContent">
          <span>草稿</span>
        </div>
      </div>
      <div></div>
    </div>

    <addGraph :isVisible="operState == 2"></addGraph>
  </div>
</template>
<script>
import { mapState } from "vuex";
import { sysGraphController } from "@/controller/sysGraphController";
import addGraph from './addGraph.vue'

export default {
  props: [],
  data() {
    return {
      fullscreenLoading: false,
      //缩放范围
      scaleArr: [
        {
          name: "25%",
          value: 25,
        },
        {
          name: "50%",
          value: 50,
        },
        {
          name: "75%",
          value: 75,
        },
        {
          name: "100%",
          value: 100,
        },
        {
          name: "150%",
          value: 150,
        },
      ],
      //选择的缩放范围
      selectScale: {},
      //操作状态  0 预览； 1 编辑；  2 新建
      operState: -1,
      //系统图ID
      diagramId: "",
    };
  },
  computed: {
    ...mapState(["projects"]),
  },
  methods: {
    //取消创建
    cancelCreate: function () {
      window.close();
    },
    //选择项目后要查询该项目下的专业、系统类型、系统实例
    selProjectChange: async function () {
      this.fullscreenLoading = true;
      this.systemInsArr = [];
      try {
        this.systemInsArr = await sysGraphController.getSysInstanceByProject(
          this.selProject.id,
          this.selProject.groupCode
        );
      } catch (error) {
        console.error(error);
      }
      this.fullscreenLoading = false;
    },
    //系统实例选择事件
    instanceChange: async function () {
      this.fullscreenLoading = true;
      try {
        //此时的数组内为选择的最低级节点，即系统实例
        var checkedNodes = this.$refs.instanceCascader.getCheckedNodes();
        //系统类型
        var typeNode = checkedNodes[0].parent;
        //查询系统类型下的系统模版
        var templateArr = await sysGraphController.getTemplateBySysCode(
          typeNode.data.code
        );
        this.systemTemplateArr = templateArr;
      } catch (error) {
        console.error(error);
      }
      this.fullscreenLoading = false;
    },
    //新增按钮事件
    
  },
  created() {
    this.operState = !this.$route.query.ost
      ? -1
      : parseInt(this.$route.query.ost);
    this.diagramId = !this.$route.query.did
      ? -1
      : parseInt(this.$route.query.did);
    this.selectScale = this.scaleArr[3];
  },

  mounted() {},
  components: {
      addGraph
  },
};
</script>

<style>
#divGraphEdit {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#divGraphEdit .firstRow {
  height: 96px;
  background: #ffffff;
  box-shadow: 0px 2px 10px rgb(31 36 41 / 10%);
  display: flex;
  flex-direction: column;
}

#divGraphEdit .firstOperDivContainer {
  flex: 1;
  border-bottom: solid 1px #f2f2f2;
  line-height: 48px;
}

#divGraphEdit .firstOperDivContainer > span:not(:first-child),
#divGraphEdit .operBtnDiv span {
  cursor: pointer;
}

#divGraphEdit .secondOperDivContainer {
  flex: 1;
}

#divGraphEdit .headerTitle {
  font-weight: 600;
  margin-left: 15px;
}

#divGraphEdit .operBtnDiv {
  display: inline-block;
  margin-left: 52px;
  font-weight: 500;
}

#divGraphEdit .operBtnDiv span {
  margin-left: 20px;
}

#divGraphEdit .delBtn {
  float: right;
  margin-right: 49px;
}

#divGraphEdit .imgBar {
  margin-left: 33px;
  vertical-align: middle;
}

#divGraphEdit .sanjiaoBar {
  vertical-align: middle;
}

#divGraphEdit .splitLine {
  display: inline-block;
  height: 30px;
  border-left: solid 1px #d8d8d8;
  vertical-align: middle;
  margin-left: 26px;
  border-top: none;
}

#divGraphEdit .secondOperDivContainer input {
  border: none !important;
  width: 66px;
  padding: 0;
}

#divGraphEdit .secondOperDivContainer .el-select {
  margin-left: 26px;
}

#divGraphEdit .zoomin {
  margin-left: 20px;
}

#divGraphEdit .zoomout {
  margin-left: 14px;
}

#divGraphEdit .imgLeftTop {
  vertical-align: middle;
  margin-left: 26px;
}

#divGraphEdit .rightLeftTop {
  vertical-align: middle;
  margin-left: 22px;
}

#divGraphEdit .resetBtn {
  float: right;
  margin-right: 49px;
  line-height: 48px;
  cursor: pointer;
}

#divGraphEdit .secondRow {
  flex: 1;
  display: flex;
  flex-direction: row;
}

#divGraphEdit .graphInfoContainer {
  background: #fafafa;
  width: 200px;
  height: 100%;
  box-shadow: 0px 0px 1px rgb(0 0 0 / 25%);
}

#divGraphEdit .graphInfoFirst {
  margin-top: 31px;
}

#divGraphEdit .graphInfoName {
  margin-left: 12px;
  margin-top: 21px;
}

#divGraphEdit .graphInfoFirstEdit {
  margin-right: 12px;
  float: right;
  color: #0091ff;
  cursor: pointer;
}

#divGraphEdit .graphInfoContent {
  margin-top: 12px;
  margin-left: 36px;
}
</style>