<template>
  <div class="home" ref="home" style="overflow: hidden; height: 100%">
    <div class="dash">
      <el-row>
        <el-col :span="5" class="dashtitle"
          ><h4 style="color: #fff"></h4
        ></el-col>
        <el-col style="padding-left: 0%">
          <el-button
            :disabled="disp"
            type="text" 
            size="mini"
            @click="buttoncli"
            style="float: right; margin-right: 5px; height: 28px;color:#fff"
            ><i class="el-icon-s-help"></i>全屏</el-button
          >
          <el-button
             type="text"
            size="mini"
            @click="save"
            style="float: right; margin-right: 10px; height: 28px;color:#fff"
            ><i class="el-icon-circle-check"></i>保存</el-button
          >
          <el-button
            type="text"
            size="mini"
            @click="back"
            style="float: right; margin-right: 0px; height: 28px;color:#fff"
            ><i class="el-icon-refresh"></i>重置</el-button
          >
          <el-button
            type="text"
            size="mini"
            @click="configuration"
            style="float: right; margin-right: 0px; height: 28px;color:#fff"
            ><i class="el-icon-menu"></i>修改配置</el-button
          >
        </el-col>
      </el-row>
      <div id="conmentId"
        v-if="zooninfalg"
        class="component overview_scroll"
        ref="home1"
      >
        <grid-layout
          :layout="layout"
          :col-num="24"
          :row-height="screen"
          :autoSize="true"
          :is-draggable="false"
          :is-resizable="true"
          :useCssTransforms="true"
          :vertical-compact="true"
          :margin="[5, 5]"
          :use-css-transforms="true"
          :style="vhhfalg?'':'height:'+vhh+'px;overflow-y:auto;overflow-x:hidden;cursor:pointer'"
        >
          <grid-item  :id="item.component"
            v-for="item in layout"
            :key="item.i"
            :x="item.x"
            :y="item.y"
            :w="item.w"
            :h="item.h"
            :i="item.i"
            @move="moveEvent"
            @moved="movedEvent"
            class="griditem"
          >
            <el-row class="drag-title">
              <el-form  :inline="true"  class="demo-form-inline">
                <div style="display: flex;">
                    <div style="display: flex;justify-content: space-between;flex-grow:24;">
                      <el-form-item>
                          <span style="color: #fff; font-weight: bold">{{item.i}}</span>
                      </el-form-item>
                    </div>
                    <div style="display: flex;justify-content: space-between;flex-grow:1;">
                      <el-form-item v-if="item.functionGroup[0]==0 || item.functionGroup[1]==0 || item.functionGroup[2]==0 ">
                        <el-tooltip class="item" effect="dark" content="切换组件功能" placement="top">
                           <el-button   type="primary" size="mini" @click.native="handleCommand(item)" icon="el-icon-menu"  circle></el-button>
                        </el-tooltip> 
                      </el-form-item>
                       <el-form-item v-if="item.functionGroup[0]==1 || item.functionGroup[1]==1 || item.functionGroup[2]==1">
                        <el-tooltip class="item" effect="dark" content="进入该功能" placement="top">
                           <el-button   type="primary" size="mini" @click.native="goto(item)" icon="el-icon-position"  circle></el-button>
                        </el-tooltip>
                      </el-form-item>
                      <el-form-item  v-if="item.functionGroup[0]==2||item.functionGroup[1]==2||item.functionGroup[2]==2">
                        <el-tooltip class="item" effect="dark" content="放大组件" placement="top">
                           <el-button  type="primary" size="mini" @click.native="zoomin(item)" icon="el-icon-view"  circle></el-button> 
                        </el-tooltip>
                      </el-form-item>
                    </div>
                  </div>
              </el-form>
            </el-row>
            <el-row class="drag-content">
              <el-col :span="24">
                <component v-bind:is="item.component" :item="item" :height="item.h"  :fatherMethod="getlayout"></component>
              </el-col>
            </el-row>
          </grid-item>
        </grid-layout>
      </div>
      <!--放大当前组件-->
      <div id="conmentId"
        v-if="zoonfalg"
        class="component overview_scroll"
        style="overflow-y: auto"
      >
        <grid-layout
          :layout="zoondata"
          :col-num="24"
          :row-height="screen"
          :autoSize="true"
          :is-draggable="false"
          :is-resizable="true"
          :useCssTransforms="true"
          :vertical-compact="true"
          :margin="[5, 5]"
          :use-css-transforms="true"
          :style="vhhfalg?'':'height:'+vhh+'px;overflow-y:auto;overflow-x:hidden;cursor:pointer'"
        >
          <grid-item
            v-for="item in zoondata"
            :key="item.i"
            :x="0"
            :y="0"
            :w="24"
            :h="24"
            :i="item.i"
            class="griditem"
          >
            <el-row class="drag-title">
               <el-form :inline="true"  class="demo-form-inline">
                  <el-form-item>
                    <span style="color: #fff; font-weight: bold">{{item.i}}</span>
                  </el-form-item>
                  <el-form-item  style="float:right">
                    <el-tooltip class="item" effect="dark" content="返回" placement="top">
                     <el-button  v-if="falg" type="primary" size="mini" @click.native="backff" icon="el-icon-refresh-left"  circle></el-button>
                    </el-tooltip>
                  </el-form-item>
                  <el-form-item>

                  </el-form-item>
               </el-form>
            </el-row>
            <el-row class="drag-content">
              <el-col :span="24" >
                <component
                 v-bind:is="item.component" 
                :item2="item"
                 :height2="item.h" 
                 :fatherMethod="getlayout"></component>
              </el-col>
            </el-row>
          </grid-item>
        </grid-layout>
      </div>
    </div>
    <div class="formatLayout">
      <el-dialog :close-on-click-modal="false"
        title="版式布局"
        :visible.sync="formatLayoutVisible"
        
        :show-close="false"
        custom-class="dashDialog"
        size="small"
      >
        <div class="content">
          <el-row>
            <el-col :span="22" :push="1">
              <div class="header bg-purple-dark">选择版式布局</div>
            </el-col>
          </el-row>
          <el-row :gutter="10">
            <el-col :span="4" v-for="(item, index) in layTable" :key="item.id">
              <div class="grid-content bg-purple-light" @click="layView(item)">
                <img v-bind:src="item.src" />
              </div>
            </el-col>
          </el-row>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="formatLayoutVisible = false">取 消</el-button>
        </span>
      </el-dialog>
    </div>
    <!--切换组件-->
    <el-dialog :close-on-click-modal="false" title="功能组件" :visible.sync="dialogTableVisible" width="30%">
      <!-- 选取功能切换:<el-select
        v-model="componentlistchange"
        filterable
        style="width: 90%"
        @change="componentchange"
        placeholder="请选择功能组件"
      >
        <el-option
          v-for="item in componentData"
          :key="item.code"
          :label="item.name"
          :value="{
            value: item.code,
            label: item.name,
            path: item.path,
            functionGroup: item.functionGroup,
          }"
        >
        </el-option>
      </el-select> -->
      <el-form label-width="110px">
       <el-form-item label="功能切换:">
        <el-cascader style="width:100%;" ref="xzCascader"
        v-model="componentlistchange"
        :options="componentData"
        :props="defaultProps"
        @change="componentchange">
      </el-cascader>
      </el-form-item>
       </el-form>
      <!-- <el-table
        ref="multipleTable"
        :data="componentData"
        border
        height="450"
        style="width: 100%; margin-top: 10px"
        @selection-change="SelectionChange"
      >
        <el-table-column align="center" label="功能名称" prop="name">
        </el-table-column>
        <el-table-column align="center" prop="componentPath" label="组件路径" > </el-table-column> 
        <el-table-column align="center" prop="code" label="组件描述">
        </el-table-column>
      </el-table>-->
      <span slot="footer" class="dialog-footer">
        <el-button  @click="back">取消切换</el-button>
        <el-button type="primary" @click="submitcomp">确认提交</el-button>
        
      </span>
    </el-dialog>
    <!--配置修改-->
    <el-dialog :close-on-click-modal="false" title="修改配置" :visible.sync="dialogTableVisible1">
      <el-table
        ref="multipleTable"
        :data="homepagelist"
        border
        style="width: 100%; margin-top: 10px"
      >
        <el-table-column align="center" label="页面名称" prop="name">
        </el-table-column>
        <el-table-column align="center" prop="path" label="页面路径">
        </el-table-column>
        <el-table-column align="center">
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.path !== '/dashboard/index'"
              @click="editpage(scope.row.id)"
              type="primary"
              class="el-icon-edit"
              size="mini"
              >修改</el-button
            >
            <el-button
              v-if="scope.row.path !== '/dashboard/index'"
              @click="deletepage(scope.row.id)"
              class="el-icon-delete"
              size="mini"
              type="danger"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog :close-on-click-modal="false" title="修改" :visible.sync="dialogTableVisible3">
      <el-row :gutter="20" >
        <el-col :span="12">
          <el-tag type="primary">配置页名称:</el-tag>
          
          <el-tag type="danger" style="color: red">注意:同版式布局最多只能配置3个首页</el-tag>

          <el-form :inline="false" style="margin-top:10px">
              <el-form-item label="设置页面名称:">
                <el-input style="width:70%" v-model="input"></el-input>              
              </el-form-item>
              <el-form-item label="设置首页图标:">
                <el-popover
              placement="bottom-start"
              width="460"
              trigger="click"
              @show="$refs['iconSelect'].reset()"
            >
              <IconSelect ref="iconSelect" @selected="handleIconSelected" />
              <el-input
                slot="reference"
                v-model="icon"
                placeholder="点击选择图标"
                style="width: 70%; margin-top: 5px"
              >
                <svg-icon
                  v-if="icon"
                  slot="prefix"
                  :icon-class="icon"
                  class="el-input__icon"
                  style="height: 40px; width: 16px"
                />
                <i v-else slot="prefix" class="el-icon-search el-input__icon" />
              </el-input>
            </el-popover>
              </el-form-item>
          </el-form>
          <el-tag type="primary" style="margin-top: 15px">布局版式</el-tag>
          <div
            class="demo-input-suffix"
            style="margin-top: 15px; margin-left: 2%"
          >
            <el-radio-group
              v-model="radio"
              disabled
              style="margin-top: 15px; width: 100px"
            >
              <el-radio :label="1"
                >大屏模式1<el-image :src="layou1tsrc"></el-image
              ></el-radio>
             
              <el-radio class="radio" :label="3"
                >常规模式1<el-image :src="layou3tsrc"></el-image
              ></el-radio>
              <el-radio class="radio" :label="4"
                >常规模式2<el-image :src="layou4tsrc"></el-image
              ></el-radio>
              <el-radio class="radio" :label="5"
                >常规模式3<el-image :src="layou5tsrc"></el-image
              ></el-radio>
            
            </el-radio-group>
          </div>
        </el-col>
        <el-col :span="12">
          <el-tag type="primary">组件选取:</el-tag>
          <el-tag type="danger" style="color: red"
            >注意:请根据布局板式个数选取组件个数</el-tag
          >
          <!-- <el-table 
                  ref="multipleTable"
                  :data="componentData"
                  border
                  style="width: 100%; margin-top: 10px;"
                  @selection-change="handleSelectionChange">
                  <el-table-column align="center" type="selection" width="55" prop="id"> </el-table-column>
                  <el-table-column align="center" label="功能名称"  prop="componentName"> </el-table-column>
                  <el-table-column  align="center" prop="componentAlias" label="组件名称" > </el-table-column>
                </el-table>  -->
          <div
            class="overview_scroll"
            style="
              margin-top: 10px;
              height: 500px;
              overflow-y: auto;
              overflow-x: hidden;
            "
          >
            <el-tree
              style="left: 20%"
              ref="tree"
              default-expand-all
              :data="menuOptions"
              :props="defaultPropst"
              show-checkbox
              node-key="id"
              :check-strictly="checkStrictly"
              @check="treeckeck"
              highlight-current
            />
            <!-- <el-tree
              style="left: 20%"
              ref="tree"
               :default-expanded-keys="expandedKeys"
              
              :data="menuOptions"
              :props="defaultProps"
              show-checkbox
              node-key="id"
              check-strictly
              @check="treeckeck"
              highlight-current
            /> -->
          </div>
        </el-col>
        <el-col :span="24" style="margin-top: 15px; text-align: center">
          <el-button class="el-icon-s-tools" type="primary" @click="organizpage"
            >合成首页</el-button
          >
          <el-button class="el-icon-check" type="primary" @click="submit"
            >确认提交</el-button
          >
        </el-col>
      </el-row>
    </el-dialog>
    <!--自定义布局首页-->
    <el-dialog :close-on-click-modal="false" title="自定义布局样式绘制" :visible.sync="dialogTableVisible2">
      <div class="component" style="overflow-y: auto">
        <grid-layout
          :layout="layout"
          :col-num="24"
          :row-height="33.4"
          :autoSize="true"
          :is-draggable="true"
          :is-resizable="true"
          :useCssTransforms="true"
          :vertical-compact="true"
          :margin="[10, 10]"
          :use-css-transforms="true"
        >
          <grid-item
            v-for="item in layout2"
            :key="item.i"
            :x="item.x"
            :y="item.y"
            :w="item.w"
            :h="item.h"
            :i="item.i"
            @move="moveEvent"
            @moved="movedEvent"
            class="griditem"
          >
            <el-row class="drag-title">
              <el-col :span="23"
                ><span style="color: green; font-weight: bold"
                  >配置组件{{ item.i }}</span
                ></el-col
              >
              <el-col :span="1" class="ico" style="cursor: pointer">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">
                    <i class="el-icon-arrow-down el-icon--right"></i>
                  </span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>切换组件功能</el-dropdown-item>
                    <el-dropdown-item @click.native="goto()"
                      >进入该功能</el-dropdown-item
                    >
                  </el-dropdown-menu>
                </el-dropdown>
              </el-col>
            </el-row>
            <el-row class="drag-content">
              <el-col :span="24">
                <component v-bind:is="item.component"></component>
              </el-col>
            </el-row>
          </grid-item>
        </grid-layout>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import axios from "axios";
import $ from "jquery";
import { getMenus } from "@/utils/auth";
import screenfull from "screenfull";
import IconSelect from "@/components/IconSelect";
import {
  homepage,
  addOverview,
  componentlist,
  detehomepage,
  gethomepage,
  updatehomepage,
} from "@/api/admin/user";
import areaconstf47 from "@/views/componentschild/areaconstf47";
import areaconstitic from "@/views/componentschild/areaconstitic";
import areaconsttype from "@/views/componentschild/areaconsttype";
import areaconsttypetable from "@/views/componentschild/areaconsttypetable";
import areaconstyy from "@/views/componentschild/areaconstyy";
import areaconstyytable from "@/views/componentschild/areaconstyytable";
import areahotable from "@/views/componentschild/areahotable";
import areahottu from "@/views/componentschild/areahottu";
import areamontormap from "@/views/componentschild/areamontormap";
import areamontortable from "@/views/componentschild/areamontortable";
import areaseveritytu from "@/views/componentschild/areaseveritytu";
import areatransienttable from "@/views/componentschild/areatransienttable";
import areaview from "@/views/componentschild/areaview";
import areaviewdydj from "@/views/componentschild/areaviewdydj";
import areaviewmonth from "@/views/componentschild/areaviewmonth";
import compevaluation from "@/views/componentschild/compevaluation";
import datantegritydiagram from "@/views/componentschild/datantegritydiagram";
import dstortionratest from "@/views/componentschild/dstortionratest";
import f47curveianalysisi from "@/views/componentschild/f47curveianalysisi";
import harmonicfz from "@/views/componentschild/harmonicfz";
import harmonicspectrum from "@/views/componentschild/harmonicspectrum";
import harmonictable from "@/views/componentschild/harmonictable";
import harmonictu from "@/views/componentschild/harmonictu";
import iticcurveianalysisi from "@/views/componentschild/iticcurveianalysisi";
import onliedataity from "@/views/componentschild/onliedataity";
import onlinerate from "@/views/componentschild/onlinerate";
import operationanalysis from "@/views/componentschild/operationanalysis";
import overviewdistrib from "@/views/componentschild/overviewdistrib";
import powerquality from "@/views/componentschild/powerquality";
import powerqualitybg from "@/views/componentschild/powerqualitybg";
import powerqualitymap from "@/views/componentschild/powerqualitymap";
import sagdistribution from "@/views/componentschild/sagdistribution";
import seadsstatestandard from "@/views/componentschild/seadsstatestandard";
import steadyratechart from "@/views/componentschild/steadyratechart";
import steadystaterate from "@/views/componentschild/steadystaterate";
import tenharmonictabletu from "@/views/componentschild/tenharmonictabletu";
import terminalconts from "@/views/componentschild/terminalconts";
import terminalstatus from "@/views/componentschild/terminalstatus";
import terminaonlinetu from "@/views/componentschild/terminaonlinetu";
import terminaoptstatustu from "@/views/componentschild/terminaoptstatustu";
import timedistribution from "@/views/componentschild/timedistribution";
import voltagecause from "@/views/componentschild/voltagecause";
import voltagesagdensity from "@/views/componentschild/voltagesagdensity";
import voltagesagtable from "@/views/componentschild/voltagesagtable";
import voltagetype from "@/views/componentschild/voltagetype";
import areaseveritytable from '@/views/componentschild/areaseveritytable'
import compentwuqutu from "@/views/componentschild/compentwuqutu";
import areamontortu from "@/views/componentschild/areamontortu";



import user from "@/views/sys/user-boot/user/index.vue";
import vueGridLayout from "vue-grid-layout";
var GridLayout = vueGridLayout.GridLayout;
var GridItem = vueGridLayout.GridItem;
export default {
  data() {
    return {
      disp:false,
      vhh:null,
      icon: "",
      vhhfalg:false,
      zoondata: [],
      falg: true,
      zoomfalg: true,
      zooninfalg: true,
      zoonfalg: false,
      mainHeight: undefined,
      mainHeight1: undefined,
      menuOptions: [],
      expandedKeys: [],
      menu: undefined,
      initialCheckedMenuIds: [], //初始选中值
      checkedMenuIds: [],
      isRoot: false, // 是否是超级管理员账户
      checkStrictly: false,
      defaultProps: {
        children: "children",
        label: "name",
        value:'id',
        expandTrigger: 'hover',
      },
      defaultPropst:{
        children: "children",
        label: "name",
      },
      screen: 30,
      device: 1,
      isFullscreen: false,
      dialogTableVisible: false,
      dialogTableVisible1: false,
      dialogTableVisible2: false,
      dialogTableVisible3: false,
      /*看板*/
      layout: [],
      layouttype: "A",
      beforemove: {},
      aftermoved: {},
      formatLayoutVisible: false,
      layTable: [
        { id: 1, src: require("../../../assets/sybju/A.png"), laytype: "A" },
        { id: 2, src: require("../../../assets/sybju/B.png"), laytype: "AA" },
        { id: 3, src: require("../../../assets/sybju/D.png"), laytype: "AAA" },
        { id: 4, src: require("../../../assets/sybju/C.png"), laytype: "AB" },
        { id: 5, src: require("../../../assets/sybju/E.png"), laytype: "BA" },
        { id: 6, src: require("../../../assets/sybju/G.png"), laytype: "BA" },
      ],
      addDashVisiable: false,
      searchType: [
        { name: "所有", num: "46" },
        { name: "图表", num: "18" },
        { name: "列表", num: "17" },
        { name: "其他", num: "10" },
      ] /*看板搜索类型*/,
      searchIndex: 0,
      addDashInput: "",
      gadgetList: [],
      layou1tsrc: require("../../../assets/sybju/A.png"),
      layou2tsrc: require("../../../assets/sybju/B.png"),
      layou3tsrc: require("../../../assets/sybju/C.png"),
      layou4tsrc: require("../../../assets/sybju/D.png"),
      layou5tsrc: require("../../../assets/sybju/E.png"),
      layou6tsrc: require("../../../assets/sybju/G.png"),
      layout1: [
        {
          id: 1,
          buju: [
            { x: 0, y: 0, w: 7, h: 8, i: "1" },
            { x: 7, y: 0, w: 10, h: 16, i: "2" },
            { x: 17, y: 0, w: 7, h: 8, i: "3" },
            { x: 0, y: 8, w: 7, h: 8, i: "4" },
            { x: 17, y: 8, w: 7, h: 8, i: "5" },
            { x: 0, y: 16, w: 7, h: 8, i: "6" },
            { x: 7, y: 16, w: 10, h: 8, i: "7" },
            { x: 17, y: 16, w: 7, h: 8, i: "8" },
          ],
        },
        {
          id: 2,
          buju: [
            { x: 0, y: 0, w: 7, h: 8, i: "1" },
            { x: 7, y: 0, w: 10, h: 24, i: "2" },
            { x: 17, y: 0, w: 7, h: 8, i: "3" },
            { x: 0, y: 8, w: 7, h: 8, i: "4" },
            { x: 17, y: 8, w: 7, h: 8, i: "5" },
            { x: 0, y: 16, w: 7, h: 8, i: "6" },
            { x: 17, y: 16, w: 7, h: 8, i: "7" },
          ],
        },
        {
          id: 3,
          buju: [
            { x: 0, y: 0, w: 8, h: 8, i: "1" },
            { x: 8, y: 0, w: 8, h: 8, i: "2" },
            { x: 16, y: 0, w: 8, h: 8, i: "3" },
            { x: 0, y: 8, w: 8, h: 8, i: "4" },
            { x: 8, y: 8, w: 8, h: 8, i: "5" },
            { x: 16, y: 8, w: 8, h: 8, i: "6" },
            { x: 0, y: 16, w: 8, h: 8, i: "7" },
            { x: 8, y: 16, w: 8, h: 8, i: "8" },
            { x: 16, y: 16, w: 8, h: 8, i: "9" },
          ],
        },
        {
          id: 4,
          buju: [
            { x: 0, y: 0, w: 12, h: 8, i: "1" },
            { x: 12, y: 0, w: 12, h: 8, i: "2" },
            { x: 0, y: 8, w: 12, h: 8, i: "3" },
            { x: 12, y: 8, w: 12, h: 8, i: "4" },
            { x: 0, y: 16, w: 12, h: 8, i: "5" },
            { x: 12, y: 16, w: 12, h: 8, i: "6" },
          ],
        },
        {
          id: 5,
          buju: [
            { x: 0, y: 0, w: 6, h: 6, i: "1" },
            { x: 6, y: 0, w: 6, h: 6, i: "2" },
            { x: 12, y: 0, w: 6, h: 6, i: "3" },
            { x: 18, y: 0, w: 6, h: 6, i: "4" },
            { x: 0, y: 6, w: 12, h: 9, i: "5" },
            { x: 12, y: 6, w: 12, h: 9, i: "6" },
            { x: 0, y: 15, w: 12, h: 9, i: "7" },
            { x: 12, y: 15, w: 12, h: 9, i: "8" },
          ],
        },
        {
          id: 6,
          buju: [
            { x: 0, y: 0, w: 8, h: 6, i: "1" },
            { x: 8, y: 0, w: 8, h: 6, i: "2" },
            { x: 16, y: 0, w: 8, h: 6, i: "3" },
            { x: 0, y: 6, w: 12, h: 9, i: "4" },
            { x: 0, y: 6, w: 12, h: 9, i: "5" },
            { x: 0, y: 15, w: 12, h: 9, i: "6" },
            { x: 12, y: 15, w: 12, h: 9, i: "7" },
          ],
        },
        {
          id: 7,
          buju: [
            { x: 0, y: 0, w: 24, h: 8, i: "1" },
            { x: 0, y: 8, w: 6, h: 8, i: "2" },
            { x: 6, y: 8, w: 18, h: 8, i: "3" },
            { x: 0, y: 16, w: 8, h: 8, i: "4" },
            { x: 8, y: 16, w: 8, h: 8, i: "5" },
            { x: 16, y: 16, w: 8, h: 8, i: "6" },
          ],
        },
      ],
      layout2: [
        { x: 0, y: 0, w: 2, h: 6, i: "1" },
        { x: 2, y: 0, w: 2, h: 6, i: "2" },
        { x: 4, y: 0, w: 2, h: 6, i: "3" },
        { x: 0, y: 6, w: 3, h: 8, i: "4" },
        { x: 3, y: 6, w: 3, h: 8, i: "5" },
        { x: 0, y: 12, w: 3, h: 8, i: "6" },
        { x: 3, y: 12, w: 3, h: 8, i: "7" },
      ],
      options: [
        {
          value: "/home/home1",
          label: "/home/home1",
        },
        {
          value: "/home/home2",
          label: "/home/home2",
        },
        {
          value: "/home/home3",
          label: "/home/home3",
        },
        {
          value: "/home/home4",
          label: "/home/home4",
        },
        {
          value: "/home/home5",
          label: "/home/home5",
        },
        {
          value: "/home/home6",
          label: "/home/home6",
        },
      ],
      pathvalue: "",
      radio: null,
      input: "",
      path: "",
      componentData: [],
      componentlist: [],
      componentlistchange: "",
      falgid: "",
      homePageIndex: "",
      formList: [],
      homepagelist: [],
      componentarr: [],
      falg: true,
      grid1: "grid1",
      grid2: "grid2",
    };
  },
  components: {
    areaconstf47,
    areaconstitic,
    areaconsttype,
    areaconsttypetable,
    areaconstyy,
    areaconstyytable,
    areahotable,
    areahottu,
    areamontormap,
    areamontortable,
    areaseveritytu,
    areatransienttable,
    areaview,
    areaviewdydj,
    areaviewmonth,
    compevaluation,
    datantegritydiagram,
    dstortionratest,
    f47curveianalysisi,
    harmonicfz,
    harmonicspectrum,
    harmonictable,
    harmonictu,
    iticcurveianalysisi,
    onliedataity,
    onlinerate,
    operationanalysis,
    overviewdistrib,
    powerquality,
    powerqualitybg,
    powerqualitymap,
    sagdistribution,
    seadsstatestandard,
    steadyratechart,
    steadystaterate,
    tenharmonictabletu,
    terminalconts,
    terminalstatus,
    terminaonlinetu,
    terminaoptstatustu,
    timedistribution,
    voltagecause,
    voltagesagdensity,
    voltagesagtable,
    voltagetype,
    areaseveritytable,
    compentwuqutu,
    areamontortu,

    IconSelect,
    GridLayout,
    GridItem,
    user,
  },
  mounted() {
    this.vhh = document.body.clientHeight - 123
    this.screen = (window.sessionStorage.getItem('appheight') )/27.1
    this.getlayout();
    this.getcomponent();
    var menuslist = window.sessionStorage.getItem("menus");
    ////console.log(eval("(" + menuslist + ")"));
    var menusArray = eval("(" + menuslist + ")");
    this.homepagelist = menusArray[0].children;
    ////console.log(this.homepagelist);
    this.pageget();
  },
  methods: {
    //放大组件功能
    zoomin(item) {
      this.disp = true;
      item.w = 24;
      item.h = 24;
      this.zoondata = [];
      this.zoondata.push(item);
      this.zoomfalg = true;
      this.zooninfalg = false;
      this.zoonfalg = true;
    },
    backff() {
      this.disp = false;
      this.zooninfalg = true;
      this.zoonfalg = false;
      this.zoomfalg = false;
      this.getlayout();
    },
    //下拉判断组件拥有的功能
    clickdown(item) {
      this.qrfalg = false;
      this.jrfalg = false;
      this.fdfalg = false;
      for (var i = 0; i < item.functionGroup.length; i++) {
        if (item.functionGroup[i] == 0) {
          this.qrfalg = true;
        }
        if (item.functionGroup[i] == 1) {
          this.jrfalg = true;
        }
        if (item.functionGroup[i] == 2) {
          this.fdfalg = true;
        }
      }
      //console.log("我被触发了");
    },
    treeckeck() {
      const checkedMenuIds = this.$refs.tree
        .getCheckedNodes(false, true)
        .map((node) => node);
      this.componentlist = checkedMenuIds;
      //console.log(checkedMenuIds);
    },
    //修改配置
    editpage(id) {
      this.dialogTableVisible1 = false;
      this.dialogTableVisible3 = true;
      this.homePageIndex = id;
      var data = {
        id: id,
      };
      gethomepage(data).then((response) => {
        
        this.input = response.data.name;
        this.icon = response.data.icon;
        let arr = eval("(" + response.data.layout + ")");
        this.componentarr = arr;
        let arr2 = [];
        for (var i = 0; i < this.componentlist.length; i++) {
          for (var j = 0; j < arr.length; j++) {
            if (this.componentlist[i].code === arr[j].component) {
              arr2.push(this.componentlist[i].id)
            }
          }
        }
        this.$nextTick(() => {
         //this.$refs.tree.setCheckedKeys('要赋值的数组')
         this.$refs.tree.setCheckedKeys(arr2);
         this.checkStrictly = false;
       });
        //this.$refs.tree.setCheckedKeys(arr2);
        
        //arr.forEach(row => {

        //  });
        this.path = response.data.path;
        if (
          response.data.path == "/home/screen1/home1" ||
          response.data.path == "/home/screen1/home2" ||
          response.data.path == "/home/screen1/home3"
        ) {
          this.radio = 1;
        } else if (
          response.data.path == "/home/screen2/home1" ||
          response.data.path == "/home/screen2/home2" ||
          response.data.path == "/home/screen2/home3"
        ) {
          this.radio = 2;
        } else if (
          response.data.path == "/home/buju1/home1" ||
          response.data.path == "/home/buju1/home2" ||
          response.data.path == "/home/buju1/home3"
        ) {
          this.radio = 3;
        } else if (
          response.data.path == "/home/buju2/home1" ||
          response.data.path == "/home/buju2/home2" ||
          response.data.path == "/home/buju2/home3"
        ) {
          this.radio = 4;
        } else if (
          response.data.path == "/home/buju3/home1" ||
          response.data.path == "/home/buju3/home2" ||
          response.data.path == "/home/buju3/home3"
        ) {
          this.radio = 5;
        } else if (
          response.data.path == "/home/buju4/home1" ||
          response.data.path == "/home/buju4/home2" ||
          response.data.path == "/home/buju4/home3"
        ) {
          this.radio = 6;
        }
      });
    },
    //删除页面
    deletepage(id) {
      var data = {
        id: id,
      };
      detehomepage(data).then((response) => {
        if (response.code == "A0000") {
          this.$message.success("删除首页成功");
          this.pageget();
        }
      });
    },
    pageget() {
      homepage().then((response) => {
        this.homepagelist = response.data;
      });
    },
    //切换组件
    componentchange(val) {
      const obj = this.$refs['xzCascader'].getCheckedNodes() //标签上定义的 ref值
      ////console.log('选中的行政区 obj.data=',obj[0].data.code,obj[0].data.name,obj[0].data.path)  // 打印出当前选择的value所对应的对象
      let v = obj[0].data.code
      let m = obj[0].data.name
      let p = obj[0].data.path
      let f = obj[0].data.functionGroup
      for (var i = 0; i < this.layout.length; i++) {
        if (this.layout[i].i == this.falgid) {
          this.layout[i].component = "";
          this.layout[i].component = v;
          this.layout[i].path = p;
          this.layout[i].functionGroup =f;
          this.layout[i].i = m;
        }
      }
    },
    //自定义布局逻辑
    drawerBuju() {
      this.dialogTableVisible2 = true;
    },
    back() {
      this.getlayout();
    },
    goto(item) {
      this.$router.push({ path: item.path });
    },
    submitcomp() {
      this.dialogTableVisible = false;
    },
    //获取布局
    getlayout() {
      homepage().then((response) => {
        const data = response.data;
        for (var i = 0; i < data.length; i++) {
          if (data[i].path == "/home/buju2/home2") {
            this.layout = eval("(" + data[i].layout + ")");
            return;
          }
        }
      });
    },
    //获取组件
    getcomponent() {
      componentlist().then((response) => {
        var arr = [];
        // debugger
        for (var i = 0; i < response.data.length; i++) {
          response.data[i].code ='aaa'
          for (var j = 0; j < response.data[i].children.length; j++) {
            response.data[i].children[j].code ='aaa'
            for(var k = 0; k < response.data[i].children[j].children.length; k++){
              arr.push(response.data[i].children[j].children[k]);
            }
          }
        }
        response.data.forEach(item=>{
          item.children.forEach(item1=>{
            item1.children.forEach(item2=>{
                  delete item2.children
            })
          })
        })
        this.componentData = response.data;
        this.componentlist = arr
        this.menuOptions = response.data;
        this.expandedKeys = this.menuOptions.map((node) => node.id);
      });
    },
    //合成首页
    organizpage() {
      var arr = [];
      //console.log('打印',this.componentlist)
      for (var n = 0; n < this.componentlist.length; n++) {
        if (this.componentlist[n].code != "aaa") {
          arr.push(this.componentlist[n]);
        }
      }
      this.componentlist = arr;
      if (this.input != "") {
        if (this.radio != null) {
          if (this.radio == 1) {
            if (this.componentlist.length >= 8) {
              for (var j = 0; j < this.componentlist.length; j++) {
                for (var i = 0; i < this.layout1[0].buju.length; i++) {
                  this.layout1[0].buju[i].i = this.componentlist[i].name;
                  this.layout1[0].buju[i].component = this.componentlist[i].code;
                  this.layout1[0].buju[i].path = this.componentlist[i].path;
                  this.layout1[0].buju[i].functionGroup =this.componentlist[i].functionGroup;
                }
              }
              this.formList = this.layout1[0].buju;
          //   //console.log(this.formList);
              this.$message.success("合成成功，请确认提交录入数据库");
            } else {
              this.$message.warning(
                "选取的组件个数小于布局版式个数,请根据布局板式个数选取组件个数"
              );
            }
          } else if (this.radio == 2) {
            if (this.componentlist.length >= 7) {
              for (var j = 0; j < this.componentlist.length; j++) {
                for (var i = 0; i < this.layout1[4].buju.length; i++) {
                  this.layout1[4].buju[i].i = this.componentlist[i].name;
                  this.layout1[4].buju[i].component = this.componentlist[i].code;
                  this.layout1[4].buju[i].path = this.componentlist[i].path;
                  this.layout1[4].buju[i].functionGroup =this.componentlist[i].functionGroup;
                }
              }
              this.formList = this.layout1[4].buju;
             // //console.log(this.formList);
              this.$message.success("合成成功，请确认提交录入数据库");
            } else {
              this.$message.warning(
                "选取的组件个数小于布局版式个数,请根据布局板式个数选取组件个数"
              );
            }
            ////console.log(this.layout)
          } else if (this.radio == 3) {
            if (this.componentlist.length >= 9) {
              for (var j = 0; j < this.componentlist.length; j++) {
                for (var i = 0; i < this.layout1[2].buju.length; i++) {
                  this.layout1[2].buju[i].i = this.componentlist[i].name;
                  this.layout1[2].buju[i].component =
                    this.componentlist[i].code;
                }
              }
              this.formList = this.layout1[2].buju;
              // //console.log(this.formList);
              this.$message.success("合成成功，请确认提交录入数据库");
            } else {
              this.$message.warning(
                "选取的组件个数小于布局版式个数,请根据布局板式个数选取组件个数"
              );
            }
            // //console.log(this.layout)
          } else if (this.radio == 4) {
            if (this.componentlist.length >= 8) {
              for (var j = 0; j < this.componentlist.length; j++) {
                for (var i = 0; i < this.layout1[4].buju.length; i++) {
                  this.layout1[4].buju[i].i = this.componentlist[i].name;
                  this.layout1[4].buju[i].component = this.componentlist[i].code;
                  this.layout1[4].buju[i].path = this.componentlist[i].path;
                  this.layout1[4].buju[i].functionGroup =this.componentlist[i].functionGroup;
                }
              }
              this.formList = this.layout1[4].buju;
            //  //console.log(this.formList);
              this.$message.success("合成成功，请确认提交录入数据库");
            } else {
              this.$message.warning(
                "选取的组件个数小于布局版式个数,请根据布局板式个数选取组件个数"
              );
            }
            // //console.log(this.layout)
          } else if (this.radio == 5) {
            if (this.componentlist.length >= 8) {
              for (var j = 0; j < this.componentlist.length; j++) {
                for (var i = 0; i < this.layout1[4].buju.length; i++) {
                  this.layout1[4].buju[i].i = this.componentlist[i].name;
                  this.layout1[4].buju[i].component =
                    this.componentlist[i].code;
                }
              }
              this.formList = this.layout1[4].buju;
              // //console.log(this.formList);
              this.$message.success("合成成功，请确认提交录入数据库");
            } else {
              this.$message.warning(
                "选取的组件个数小于布局版式个数,请根据布局板式个数选取组件个数"
              );
            }
            // //console.log(this.layout)
          } else if (this.radio == 6) {
            if (this.componentlist.length >= 7) {
              for (var j = 0; j < this.componentlist.length; j++) {
                for (var i = 0; i < this.layout1[5].buju.length; i++) {
                  this.layout1[5].buju[i].i = this.componentlist[i].name;
                  this.layout1[5].buju[i].component =
                    this.componentlist[i].code;
                }
              }
              this.formList = this.layout1[5].buju;
              // //console.log(this.formList);
              this.$message.success("合成成功，请确认提交录入数据库");
            } else {
              this.$message.warning(
                "选取的组件个数小于布局版式个数,请根据布局板式个数选取组件个数"
              );
            }
          } else if (this.radio == 7) {
            if (this.componentlist.length >= 7) {
              for (var j = 0; j < this.componentlist.length; j++) {
                for (var i = 0; i < this.layout1[6].buju.length; i++) {
                  this.layout1[6].buju[i].i = this.componentlist[i].name;
                  this.layout1[6].buju[i].component =
                    this.componentlist[i].code;
                }
              }
              this.formList = this.layout1[6].buju;
              // //console.log(this.formList);
              this.$message.success("合成成功，请确认提交录入数据库");
            } else {
              this.$message.warning(
                "选取的组件个数小于布局版式个数,请根据布局板式个数选取组件个数"
              );
            }
          } ////console.log(this.layout)
        } else {
          this.$message.warning("请选择布局版式");
        }
      } else {
        this.$message.warning("请设置页面名称");
      }
    },
    //选取的组件集合
    handleSelectionChange(val) {
      this.componentlist = val;
    },
    //切花组件集和
    SelectionChange(val) {
      //alert(val)
      //this.componentlistchange=val
    },
    handleIconSelected(name) {
      this.icon = name;
      this.$forceUpdate();
    },
    //提交数据
    submit() {
      this.organizpage();
      let homePageBO = {
        icon: this.icon,
        id: this.homePageIndex,
        name: this.input,
        path: this.path,
        layout: JSON.stringify(this.formList),
        sort: 0,
      };
      updatehomepage(homePageBO).then((response) => {
        if (response.code == "A0000") {
          this.$message({
            message: response.message,
            type: "success",
          });
          this.pageget();
        }
        this.dialogTableVisible1 = false;
        this.dialogTableVisible3 = false;
      });
    },
    configuration() {
      this.dialogTableVisible1 = true;
    },
    buttoncli() {
      if(!this.vhhfalg){
        this.vhhfalg = true
      }else{
        this.vhhfalg = false
      }
      if (screenfull.enabled) {
        // 如果不允许进入全屏，发出不允许提示
        this.$message({
          message: "不支持全屏",
          type: "warning",
        });
        return false;
      }
      if(this.falg){
        this.falg = false
        this.screen = (window.sessionStorage.getItem('appheight') )/22.6
      }else{
        this.falg = true
        this.screen = (window.sessionStorage.getItem('appheight') )/27.1
      } 
      screenfull.toggle(this.$refs.home);

      this.$message({
        message: "全屏啦",
        type: "success",
      });
    },

    formatter(row, column) {
      return row.address;
    },
    cellClick(row, column, cell, event) {
      this.$message({ type: "info", message: "点我" });
    },
    moveEvent: function (i, newX, newY) {
      //console.log("MOVE i=" + i + ", X=" + newX + ", Y=" + newY);
      this.beforemove = { i: i, x: newX, y: newY };
    },
    movedEvent: function (i, newX, newY, newW, newH) {
      for (var j = 0; j < this.layout.length; j++) {
        if (this.layout[j].i == i) {
          "X=" + newX, "Y=" + newY, "W=" + newW, "H=" + newH;
        }
      }
      //console.log("MOVED i=" + i + ", X=" + newX + ", Y=" + newY);
    },
    save() {
     // //console.log("=========================================");
     // //console.log(this.homepagelist);
      var Index = "";
      var name = "";
      for (var i = 0; i < this.homepagelist.length; i++) {
        if (this.homepagelist[i].path === "/home/buju2/home2") {
          Index = this.homepagelist[i].id;
          name = this.homepagelist[i].name;
        }
      }
      let homePageBO = {
       // icon: this.icon,
        id: Index,
        name: name,
        path: "/home/buju2/home2",
        layout: JSON.stringify(this.layout),
        sort: 0,
      };
      updatehomepage(homePageBO).then((response) => {
        if (response.message) {
          this.$message({
            message: response.message,
            type: "success",
          });
        }
       // //console.log(this.layout);

        ////console.log('=========================================')
      });
    },

    //切换组件功能
    handleCommand(item) {
      ////console.log(item)
      this.falgid = item.i;
      this.dialogTableVisible = true;
      // item.component=this.componentlistchange
    },
    addDashButton() {
      this.addDashVisiable = true;
      this.$$api_dashBoard_getGadgetList({
        data: { queryCriteria: {} },
        fn: (data) => {
          this.gadgetList = data.data;
        },
        errFn: (err) => {
          this.$message.error(err.msg);
        },
        tokenFlag: true,
      });
    },
    searchType_Click(index) {
      this.searchIndex = index;
    },
    //    getTemplate(templateName){
    //    	return require("./../dashComponent/"+templateName+".vue");
    //    }
  },
};
</script>
<style lang="scss" scoped>
::v-deep.el-button--primary {
    color: #fefefe;
    background-color:$themeColor !important;
    border-color: $themeColor !important;
}

::v-deep.el-button--primary:hover {
    color: #fefefe;
    background-color: $themeColor !important;
    border-color: $themeColor !important;
}
::v-deep.icon-body .icon-list span[data-v-6504d548] {
    display: inline-block;
    vertical-align: -0.15em;
    fill: currentColor;
    color:#333 !important;
    overflow: hidden;
}
.dash {
  width: 100%;
  margin-top: 0px;
  height: 30px;
  padding-top: 0px;
  background-color: $themeColor;
}
.radio {
  margin-top: 50px;
}
.el-image {
  width: 60px;
  height: 60px;
  position: absolute;
  margin-top: -20px;
  margin-left: 10px;
}
.drag-title {
  font-size: 13px;
  background-color: $themeColor;
  height: 35px;
  line-height: 40px;
  padding-left: 10px;
  //border-bottom: 1px solid #EAEAEF;
}
.cssTransforms {
  // border:1px solid #cecece;
  //  border-top: 30px solid $themeColor;
}
.overview_scroll::-webkit-scrollbar-thumb {
  border-radius: 4px;
  margin-right: 5px;
  -webkit-box-shadow: inset 0 0 0px #b9b9b94d;
  background: #bcbdbd38;
}
/*定义滚动条所在轨道的样式。有圆角和阴影以及淡色系的背景色*/
.overview_scroll::-webkit-scrollbar-track {
  -webkit-box-shadow: inset 0 0 0px #bebebe4f;
  border-radius: 4px;
  background: #bebebe2c;
}
::-webkit-scrollbar {
  width: 5px;
  height: 14px;
}

::-webkit-scrollbar-thumb {
  //background-color: #01c8dc;
  border-radius: 5px;
  background-color: #d3d4d434;
}
.but {
  float: right;
  margin-right: 5px;
  height: 25px;
}
.grid1 {
  height: 80vh;
}
.grid2 {
  height: 100vh;
}
</style>
<style>
@import url("../dashView.less");
</style>
