/* 问题区 */
<template>
  <gy-card
    title="问题区"
    area-style="problem"
    circle-style="green"
    content-style="89"
    @parentRun="run"
    @contextmenu="contextmenu"
  >
    <ProblemMatrixCard title="故障" :type="5"></ProblemMatrixCard>
    <ProblemMatrixCard title="维护" :type="6"></ProblemMatrixCard>
    <ProblemMatrixCard title="离线" :type="7"></ProblemMatrixCard>
    <ProblemMatrixCard title="挂牌" :type="-1"></ProblemMatrixCard>
  </gy-card>
</template>

<script>
import ProblemMatrixCard from "./windturbine/problem/ProblemMatrixCard.vue";
import BackgroundData from "../../assets/script/BackgroundData";

export default {
  name: "ProblemArea",
  components: {
    ProblemMatrixCard,
  },
  props: {},
  data() {
    return {
      ls: {
        maintain: { key: "维护", value: [] },
        malfunction: { key: "故障", value: [] },
        offline: { key: "离线", value: [] },
        lockd: { key: "挂牌", value: [] },
      },
    };
  },
  computed: {},
  created: function () {
    this.initData();
  },
  methods: {
    /* 右键菜单 */
    contextmenu() {
      const { remote } = require("electron");
      var that = this;
      const menuTemplate = [
        {
          label: "标注",
          click() {
            that.menuClicked({ type: "marking" });
          },
        },
        {
          label: "挂牌",
          submenu: [
            {
              label: "检修",
              click() {
                that.menuClicked({ type: "lock", value: 8 });
              },
            },
            {
              label: "故障维修",
              click() {
                that.menuClicked({ type: "lock", value: 7 });
              },
            },
            {
              label: "场内受累检修",
              click() {
                that.menuClicked({ type: "lock", value: 2 });
              },
            },
            {
              label: "场内受累故障",
              click() {
                that.menuClicked({ type: "lock", value: 3 });
              },
            },
            {
              label: "场外受累电网",
              click() {
                that.menuClicked({ type: "lock", value: 4 });
              },
            },
            {
              label: "场外受累天气",
              click() {
                that.menuClicked({ type: "lock", value: 5 });
              },
            },
          ],
        },
        {
          label: "取消挂牌",
          click() {
            that.menuClicked({ type: "unlock" });
          },
        },
      ];
      const menu = remote.Menu.buildFromTemplate(menuTemplate);

      menu.popup(remote.getCurrentWindow());
    },

    menuClicked(msg) {
      var bd = BackgroundData.getInstance();
      if (!bd.LoginUser) {
        bd.showdialog("提示", "控制出现错误：", "未登录");
        return;
      }
      if (msg.type == "lock") {
        // 挂牌
      } else if (msg.type == "unlock") {
        // 取消挂牌
      } else if (msg.type == "marking") {
        // 标注
      }
    },
  },
};
</script>
