<template>
  <div
    class="mychart_container"
    id="mychart_container"
  >
    <span
      class="slide-icon slide-right"
      @click="slideHandle"
      v-show="isSlideLeft"
    >
      <i class="el-icon-d-arrow-right"></i>
    </span>
    <div class="main-left left" id="left" v-show="!isSlideLeft">
      <span class="slide-icon slide-left" @click="slideHandle">
        <i class="el-icon-d-arrow-left"></i>
      </span>
      <span class="move-btn resize" v-drag id="resize"></span>
      <div class="left-top">
        <span class="add-cont" @click="chooseChartHandle">
          <img
            :src="$icons.choose_blue"
            alt=""
            style="width: 14px; height: 14px"
          />
          选择图表
        </span>
        <el-select
          v-model="search_txt"
          v-loadMore="searchLoad"
          :filterable="!search_txt"
          remote
          clearable
          placeholder="请输入图表名称"
          style="width: 100%; margin-top: 20px"
          :remote-method="searchHandle"
          @click.native="inputFocusHandle"
        >
          <i slot="prefix" class="el-input__icon el-icon-search"></i>
          <el-option
            v-for="item in searchOptions"
            :key="item.MyChartId"
            :label="chart_lang==='en'?(item.ChartNameEn||item.ChartName):item.ChartName"
            :value="item.MyChartId"
          >
          </el-option>
        </el-select>
      </div>
      <div class="left-bottom">
        <div class="public-classify" v-if="publicClassifyList.length">
          <h3 class="classify-type">公共图库</h3>
          <ul class="public-ul">
            <li
              :class="[
                'classify-item',
                { 'act': item.MyChartClassifyId === select_classify && item.fromPublic === ispublic },
              ]"
              v-for="item in publicClassifyList"
              :key="item.MyChartClassifyId"
              @click="chooseClassify(item)"
            >
              <span>
                {{ item.MyChartClassifyName }}
              </span>
             
              <div class="right-item right-item-box" >
                <el-dropdown @command="handleCommand" trigger="click">
                  <span class="el-dropdown-link"> 
                    <i class="el-icon-more" style="font-size: 16px;transform: rotate(90deg);cursor: pointer"/>
                  </span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item :command="{key:'copy'}" :disabled="select_classify_userid === roleId">复制</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </div>
            </li>
          </ul>
        </div>
        <div class="classify" v-if="classifyList.length">
          <h3 class="classify-type">我的图库</h3>
          <draggable
            v-model="classifyList"
            class="classify-ul"
            animation="300"
            tag="ul"
            @start="menuDragStart"
            @update="menuDragenter"
            @end="menuDragOver"
          >
            <li
              :class="[
                'classify-item',
                { 'act': item.MyChartClassifyId === select_classify && item.fromPublic === ispublic },
              ]"
              v-for="item in classifyList"
              :key="item.MyChartClassifyId"
              @click="chooseClassify(item)"
            >
              <div>
                <img
                  src="~@/assets/img/data_m/move_ico.png"
                  alt=""
                  class="move"
                  style="width: 14px; height: 14px;margin-right: 5px;"
                />
                {{ item.MyChartClassifyName }}
              </div>
              <div class="right-item right-item-box">
                <el-dropdown style="margin-right: 10px" @command="handleCommand" trigger="click">
                  <span class="el-dropdown-link  el-dropdown-link-img">
                    <!-- <i class="el-icon-user" style="font-size: 16px; cursor: pointer"/> -->
                     <img src="~@/assets/img/chart_m/Group.png" v-if="item.IsPublic === 0">
                     <img src="~@/assets/img/chart_m/User.png" v-else>
                  </span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item 
                    :command="{key:'own',IsCompanyPublic:undefined,item}" 
                    :class="item.IsPublic === 0 ? 'el-dropdown-menu-item-chat-act' : ''"
                    class="el-dropdown-menu-item-chat"
                    >
                    <img v-if="item.IsPublic === 0" src="~@/assets/img/chart_m/Group_act.png">
                    <img v-else src="~@/assets/img/chart_m/Group.png">
                    仅自己可见</el-dropdown-item>
                    <el-dropdown-item 
                    :command="{key:'public',IsCompanyPublic:undefined,item}" 
                    :class="item.IsPublic === 1 ? 'el-dropdown-menu-item-chat-act' : ''"
                    class="el-dropdown-menu-item-chat"
                    >
                    <img v-if="item.IsPublic === 1" src="~@/assets/img/chart_m/User_act.png">
                    <img v-else src="~@/assets/img/chart_m/User.png">
                    所有人可见</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
                <el-dropdown @command="handleCommand" trigger="click">
                  <span class="el-dropdown-link"> 
                    <i class="el-icon-more" style="font-size: 16px;transform: rotate(90deg);cursor: pointer"/>
                  </span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item :command="{key:'edit'}">重命名</el-dropdown-item>
                    <el-dropdown-item :command="{key:'del'}">删除</el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </div>
            </li>
          </draggable>
        </div>
        <div class="noclassify" @click="addClassify">
          <img
            src="~@/assets/img/set_m/add_ico.png"
            alt=""
            style="width: 16px; height: 16px; margin-right: 10px"
          />
          <span>添加我的分类</span>
        </div>
      </div>
    </div>
    <div
      class="main-right right"
      id="right"
      :style="isSlideLeft ? 'width:100%' : ``"
    >
      <div class="chart-public-cont" v-if="haveData">
        
        <div class="cont-top">
          <span>共{{ total }}张图表</span>
          <span v-if="ispublic === 1">分享人: {{ publicClassifyList.find(item => item.MyChartClassifyId === select_classify).RealName}}</span>
        </div>
        <div
          class="chart-public-list"
          :infinite-scroll-disabled="!haveMove"
          v-infinite-scroll="loadMove"
          infinite-scroll-distance='1'
          infinite-scroll-delay="200"
        >
          <draggable
            v-model="chartList"
            class="drag-cont"
            animation="300"
            @start="dragStartHandler"
            @update="dragenter"
            @end="dragOverHandler"
            :disabled="ispublic===1"
          >
            <el-col
              :span="6"
              v-for="chart in chartList"
              :key="chart"
              style="margin-bottom: 20px; padding-right: 20px"
            >
              <el-card class="public-chart-item">
                <div slot="header" class="item-top">
                  <div class="chartEn-mark" v-show="chart.IsEnChart" style="top: -10px;left: -10px;">En</div>
                  <span class="text_oneLine" :style="{'padding-left':chart.IsEnChart?'24px':''}">{{ chart_lang === 'en' ? (chart.ChartNameEn||chart.ChartName) : chart.ChartName }}</span>
                  <img
                    v-if="ispublic === 0"
                    src="~@/assets/img/data_m/move_ico.png"
                    alt=""
                    class="move"
                    style="width: 14px; height: 14px"
                  />
                </div>
                <img
                  :src="chart.ChartImage"
                  alt=""
                  class="chart-img"
                  @click="viewChartDetail(chart)"
                />
                <div class="item-bottom">
                  <span class="last-time"
                    >创建时间: {{ chart.CreateTime.slice(0,10) }}</span
                  >
                  <div v-if="select_classify_userid === roleId">
                    <span class="join_txt" @click="removeMyChart(chart)">
                      <i
                        class="el-icon-remove-outline"
                        style="font-size: 14px"
                      ></i>
                      移出
                    </span>
                  </div>
                </div>
              </el-card>
            </el-col>
          </draggable>
        </div>
      </div>
      <div v-else class="nodata">
        <span v-if="ispublic === 1" class="sharer">分享人: {{ publicClassifyList.find(item => item.MyChartClassifyId === select_classify).RealName}}</span>
        <img
          src="~@/assets/img/data_m/table_no.png"
          alt=""
          style="
            display: block;
            width: 140px;
            height: 148px;
            margin: 10% auto 10px;
          "
        />
        暂无图表
      </div>
    </div>

    <choose-chart
      :isOpenChoose="isChoose"
      @cancel="isChoose = false"
      @addSuccess="addChartBack"
    />

    <pub-dialog
      :isShow="isClassifyDia"
      :title="dia_title"
      :keysArr="dialogKeyArrs"
      :formData="formData"
      :formRules="addRules"
      :selectArr="selectArr"
      @cancel="isClassifyDia = false"
      @ensureCallBack="addClassifyBack"
    />

    <!-- 图表详情弹窗 -->
    <chart-detail
      :isOpenDetail="isOpenDetail"
      :select_classify="select_classify"
      :chart_code="chart_code"
      :allChart="chartArrParams"
      :classifyUserId="select_classify_userid"
      @close="chartCallBack"
      @remove="removeCallBack"
    />
  </div>
</template>

<script>
import draggable from 'vuedraggable';
import { mychartInterface } from '@/api/api.js';
import pubDialog from '@/components/pubDialog.vue';
import chooseChart from './components/chooseChart.vue';
import chartDetail from './components/chartDetailDia.vue';
export default {
  name: '',
  components: {
    chooseChart,
    pubDialog,
    draggable,
    chartDetail
  },
  directives: {
    drag(el, bindings) {
      el.onmousedown = function (e) {
        var init = e.clientX;
        // console.log(init);
        var box = $('#mychart_container')[0];
        // console.log(box.clientWidth)
        let total_wid = box.offsetWidth;
        var left = $('#left')[0];
        var right = $('#right')[0];
        var initWidth = left.offsetWidth;
        document.onmousemove = function (e) {
          var end = e.clientX;
          // console.log(total_wid,initWidth,end);
          if (end > 310) {
            var newWidth = end - init + initWidth;
            // right.style.width = total_wid-end+80 +'px'
            right.style.width = total_wid - newWidth + 'px';
            left.style.width = newWidth + 'px';
          } else {
            end = 350;
            // 最小宽度300
            left.style.width = 300 + 'px';
            // right.style.width = total_wid-300-20 +'px'
          }
        };
        document.onmouseup = function () {
          document.onmousemove = document.onmouseup = null;
          e.releaseCapture && e.releaseCapture();
        };
        e.setCapture && e.setCapture();
        return false;
      };
    },
  },
  data() {
    return {
      haveData: true,
      isSlideLeft: false, //收起分类
      search_txt: '',
      searchOptions: [],
      select_classify: '',
      classifyList: [],
      total: 0,
      page_no: 1,
      page_size: 12,
      chartList: [], //列表
      isRightClick: false, //右击弹窗
      rightClick_classify: '', //右击的分类
      rightActionArr: [
        {
          title: '编辑',
          key: 'edit',
        },
        {
          title: '删除',
          key: 'del',
        },
      ],
      startIndex: '', //初始位置id
      preIndex: '', //结束位置上一个id
      nextIndex: '', //结束位置下一个id
      /* 选择图表弹窗 */
      isChoose: false,
      /* 添加分类 */
      isClassifyDia: false,
      dia_title: '新增分类',
      dialogKeyArrs: [], //form key
      selectArr: [], //select data
      formData: {
        name: '',
      },
      addRules: {
        name: [
          { required: true, message: '分类名称不能为空', trigger: 'blur' },
        ],
        classify: [
          { required: true, message: '复制分类不能为空', trigger: 'blur' },
        ],
      }, //添加分类规则
      move_id: '', //移动到 当前选中图表

      /* 图表详情弹窗 */
      isOpenDetail: false,
      chart_code: '',//图表code
      chartArrParams: [],//当前选择分类下的所有图表
      startMenuIndex: '', //初始位置id
      preMenuIndex: '', //结束位置上一个id
      nextMenuIndex: '', //结束位置下一个id

      publicClassifyList: [],//公共分类
      ispublic: '',//选中的是公共还是own
      select_classify_userid: '',//选中图表的创建人id

      chart_lang: 'ch',
    };
  },
  computed: {
    /* 登录角色id */
    roleId() {
      let id = Number(localStorage.getItem('AdminId'));
      return id;
    },
  },
  watch: {
    // 左侧选中分类
    select_classify(newval) {
      if (newval) {
        this.page_no = 1;
        this.chartList = [];
        this.getChartList();
      }
    },

    /*  */
    search_txt(newval) {
      if (newval) {
        const obj = this.searchOptions.find(
          (item) => item.MyChartId === newval
        );

        //所属分类列表 单个高亮左侧
        let classify_arr = obj.MyChartClassifyId.split(',');

        this.page_no = 1;
        this.select_classify = '';

        if (classify_arr.length === 1) this.select_classify = Number(classify_arr[0]);
        this.getChartList();
      }
    },

    //页码
    page_no() {
      this.getChartList();
    },
  },
  methods: {
    /* 获取分类列表 */
    getClassify() {
      mychartInterface.classifyList().then((res) => {
        if (res.Ret !== 200) return;
        this.chart_lang = res.Data.Language === 'EN' ? 'en' : 'ch';

        this.classifyList = res.Data ? res.Data.List.map(item => ({
          ...item,
          fromPublic: 0
        })) : [];
        if (!this.classifyList.length) this.haveData = false;

        this.select_classify =
          this.select_classify ||
          (this.classifyList.length
            ? this.classifyList[0].MyChartClassifyId
            : '');
        this.ispublic =  this.ispublic ||
          (this.classifyList.length
            ? this.classifyList[0].fromPublic
            : '');
        this.select_classify_userid = this.select_classify_userid ||  (this.classifyList.length
            ? this.classifyList[0].AdminId
            : '');   
      });
    },

    /* 获取公用分类 */
    getPublicClassify() {
      mychartInterface.publicClassify().then((res) => {
        if(res.Ret !== 200) return;
        this.publicClassifyList = res.Data ? res.Data.List.map(item => ({
          ...item,
          fromPublic: 1
        })) : [];
      })
    },

    /* 获取图表 MyChartId用于具体搜索和MyChartClassifyId互斥*/
    getChartList() {
      mychartInterface
        .myList({
          PageSize: this.page_size,
          CurrentIndex: this.page_no,
          MyChartClassifyId: this.select_classify || 0,
          MyChartId: this.search_txt || 0,
        })
        .then((res) => {
          if (res.Ret !== 200) return;
          this.haveData = res.Data ? true : false;
          this.haveMove = res.Data
            ? this.page_no < res.Data.Paging.Pages
            : false;
          this.chartList = res.Data
            ? this.page_no === 1
              ? res.Data.List
              : [...this.chartList, ...res.Data.List]
            : [];
          this.total = res.Data ? res.Data.Paging.Totals : 0;
        });
    },

    /* 加载下页 */
    loadMove() {
      this.page_no++;
    },

     /* 搜索 */
		searchHandle(query) {
			this.search_page = 1;
			this.current_search = query;
			this.searchApi(this.current_search)
		},

		searchApi(query,page=1) {
      if(!query) {
        this.searchOptions = [];
        return
      }
      /* 查找列表 */
      mychartInterface
        .mychartSearchByEs({
          Keyword: query,
          CurrentIndex: page
        })
        .then((res) => {
          if (res.Ret !== 200) return
          const { List,Paging } = res.Data;
          this.search_have_more = page < Paging.Pages;
          this.searchOptions = page === 1 ? List : [...this.searchOptions,...List];
        });
		},

		/* 聚焦获取当前检索 */
		inputFocusHandle(e) {
			this.search_page = 1;
			this.current_search = e.target.value;
      if(this.current_search) {
        this.searchApi(this.current_search)
      }else {
        this.searchOptions = [];
      }
		},

		searchLoad() {
			if(!this.search_have_more) return;
			this.searchApi(this.current_search,++this.search_page);
		},

    /* 切换分类 */
    chooseClassify({MyChartClassifyId,fromPublic,AdminId}) {
      this.select_classify = MyChartClassifyId;
      this.ispublic = fromPublic;
      this.select_classify_userid = AdminId;
      this.search_txt = '';
    },

    /* 选择图表添加 */
    chooseChartHandle() {
      this.isChoose = true;
    },
    /* 图表添加完成 */
    addChartBack() {
      this.isChoose = false;
      this.getClassify();
      this.getChartList();
    },

    /* 添加分类 */
    addClassify() {
      this.dia_title = '新增分类';
      this.dialogKeyArrs = [
        {
          label: '分类名称',
          prop: 'name',
          type: 'input',
          maxlen: 10,
          placeholder: '请输入分类名称',
        },
      ];
      this.formData = {
        name: '',
      };
      this.isClassifyDia = true;
    },

    /* 添加分类回调 */
    addClassifyBack(params, title) {
      title === '新增分类' &&
        mychartInterface
          .addClassify({
            MyChartClassifyName: params.name,
          })
          .then((res) => {
            if (res.Ret !== 200) return;
            this.$message.success('新增成功');
            this.isClassifyDia = false;
            this.getClassify();
          });

      title === '重命名分类' &&
        mychartInterface
          .editClassify({
            MyChartClassifyName: params.name,
            MyChartClassifyId: this.select_classify,
          })
          .then((res) => {
            if (res.Ret !== 200) return;
            this.$message.success('编辑成功');
            this.isClassifyDia = false;
            this.getClassify();
            this.getPublicClassify();
          });

      title === '复制图表分类' &&
        mychartInterface
          .copyMyChart({
            ChartInfoId: this.move_id,
            MyChartClassifyId: params.classify,
          })
          .then((res) => {
            if (res.Ret !== 200) return;
            this.$message.success('复制成功');
            this.isClassifyDia = false;
            // this.isOpenDetail = false;
            // this.select_classify = '';
            this.resetStatus();
            this.getClassify();
            this.getChartList();
          });
    },

    resetStatus() {
      this.search_txt = '';
    },

    /*重命名分类  */
    editClassify({ MyChartClassifyName }) {
      this.isClassifyDia = true;
      this.formData = {
        name: MyChartClassifyName,
      };
      this.dialogKeyArrs = [
        {
          label: '分类名称',
          prop: 'name',
          type: 'input',
          maxlen: 10,
          placeholder: '请输入分类名称',
        },
      ];
      this.dia_title = '重命名分类';
    },

    /* 操作 */
    handleCommand({key,IsCompanyPublic,item}) {
      console.log({key,IsCompanyPublic,item});
      key === 'copy' && mychartInterface.copyclassify({
        MyChartClassifyId: this.select_classify
      }).then(res => {
        if(res.Ret !== 200) return;
        this.$message.success('复制成功');
        this.getClassify();
      });

      ['edit','del'].includes(key) && this.dealAction(key);

      ['own', 'public'].includes(key) && mychartInterface.setPublic({
        IsPublic: key === 'own' ? 0 : 1,
        MyChartClassifyId: this.select_classify
      }).then(res => {
        if(res.Ret !== 200) return;
        this.$message.success('设置成功');
        if(key === 'own'){
          item.IsPublic=0
          item.IsCompanyPublic=0
        }else{
          item.IsPublic=1
        }
        // 不想请求接口
        // this.getPublicClassify();
        // this.getClassify();
      })

      key==='auth' && mychartInterface.setClassifyAuthToUser({
          MyChartClassifyId:this.select_classify,
          IsCompanyPublic:IsCompanyPublic
        }).then(res=>{
          if(res.Ret !== 200) return;
          this.$message.success('操作成功');
          item.IsCompanyPublic=IsCompanyPublic
          // 不想请求接口
          // this.getPublicClassify();
        })
      
    },

    /* 编辑 删除*/
    dealAction(key) {
      // this.isRightClick = false;
      key === 'del' &&
        this.$confirm(
          '若删除该分类，则分类下关联的所有图表将被全部删除, 是否继续?',
          '提示',
          {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          }
        )
          .then(() => {
            mychartInterface
              .delClassify({
                MyChartClassifyId: this.select_classify,
              })
              .then((res) => {
                if (res.Ret !== 200) return;
                this.$message.success('删除成功');
                this.getClassify();
                this.getPublicClassify();
                // if (this.rightClick_classify === this.select_classify)
                //   this.select_classify = '';
              });
          })
          .catch(() => {});

      const obj = this.classifyList.find(
        (x) => x.MyChartClassifyId === this.select_classify
      );
      key === 'edit' && this.editClassify(obj);
    },

    /* 右键菜单打开 */
    // rightClickHandle({ MyChartClassifyId }, e) {
    //   this.rightClick_classify = MyChartClassifyId;
    //   this.isRightClick = true;
    //   $('.right-content')[0].style.left = e.clientX + 'px';
    //   $('.right-content')[0].style.top = e.clientY + 'px';
    // },

    /* 拖动开始 记录位置 */
    dragStartHandler({ oldIndex }) {
      this.startIndex = this.chartList[oldIndex].MyChartId;
    },

    /* 拖动结束 替换  */
    dragOverHandler() {
      // if (this.startIndex === this.preIndex) return;
      mychartInterface
        .move({
          MyChartId: this.startIndex,
          MyChartClassifyId: this.select_classify,
          PrevMyChartId: this.preIndex || 0,
          NextMyChartId: this.nextIndex || 0,   
        })
        .then((res) => {
          if (res.Ret !== 200) return;
        });
    },

    /* 拖动时 获取移动后的上一个位置id 若移到第一位则取0 获取后一个id 若是最后一个取0*/
    dragenter({ newIndex }) {
      console.log(newIndex)
      this.preIndex = newIndex > 0 ? this.chartList[newIndex - 1].MyChartId : 0;
      this.nextIndex = newIndex ===  this.chartList.length - 1 ? 0 : this.chartList[newIndex + 1].MyChartId
    },

     /* 拖动开始 记录位置 */
    menuDragStart({ oldIndex }) {
      this.startMenuIndex = this.classifyList[oldIndex].MyChartClassifyId;
    },

    /* 拖动结束 替换  */
    menuDragOver() {
      mychartInterface.moveClassify({
          MyChartClassifyId:  this.startMenuIndex,
          NextClassifyId: this.nextMenuIndex || 0,
          PrevClassifyId:  this.preMenuIndex || 0,
      }).then(res => {
        if(res.Ret !== 200) return;
      })

    },

    /* 拖动时 获取移动后的上一个位置id 若移到第一位则取0 获取后一个id 若是最后一个取0*/
    menuDragenter({ newIndex }) {
      
      this.preMenuIndex = newIndex > 0 ? this.classifyList[newIndex - 1].MyChartClassifyId : 0;
      this.nextMenuIndex = newIndex ===  this.classifyList.length - 1 ? 0 : this.classifyList[newIndex + 1].MyChartClassifyId

    },

    /* 向左收起/展开 */
    slideHandle() {
      this.isSlideLeft = !this.isSlideLeft;
    },

    /* 页码改变 */
    handleCurrentChange(page) {
      this.page_no = page;
    },

    /* 进入图库详情 */
    async viewChartDetail({ UniqueCode }) {
      this.chart_code = UniqueCode;

      // 获取当前分类下的所有图表 取code
      const allcharts =  (this.select_classify || this.search_txt)  ? await mychartInterface
        .myList({
          PageSize: 1000000,
          CurrentIndex: 1,
          MyChartClassifyId: this.select_classify || 0,
          MyChartId: this.search_txt || 0,
        }) : []; 
      this.chartArrParams = allcharts.Data.List && allcharts.Data.List.length ? allcharts.Data.List.map(item => item.UniqueCode) : [];

      this.isOpenDetail = true;
    },


    chartCallBack() {
      this.page_no = 1;
      this.isOpenDetail = false;
      this.getChartList();
    },

    // 弹窗内移出删除图标后回调
    removeCallBack(code) {
      this.chartArrParams.splice(this.chartArrParams.findIndex(item => item === code), 1)
    },

    /* 移出我的图库 */
    removeMyChart({ MyChartId }) {
      if (!this.select_classify)
        return this.$message.warning(
          '当前图表所属多个分类，请选中具体分类移出'
        );
      mychartInterface
        .del({
          MyChartId,
          MyChartClassifyId: this.select_classify,
        })
        .then((res) => {
          if (res.Ret !== 200) return;
          this.$message.success('移出成功');
          this.page_no = 1;
          this.getChartList();
        });
    },
    /* 移动到 打开分类弹窗 */
    async moveMychart(id) {
      // if (!this.select_classify)
      //   return this.$message.warning(
      //     '当前图表所属多个分类，请选中具体分类移动'
      //   );
      this.dia_title = '复制图表分类';
      this.move_id = id;
      this.dialogKeyArrs = [
        {
          label: '复制到',
          prop: 'classify',
          type: 'select',
          placeholder: '请选择目录',
          multiple: true,
        },
      ];
      this.formData = {
        classify: [],
      };

      //获取当前图表所属分类并过滤
      const { Data } = await mychartInterface.getChartInClassify({ChartInfoId: id });

      this.selectArr = this.classifyList
        .map((item) => ({
          name: item.MyChartClassifyName,
          value: item.MyChartClassifyId,
        }))
        .filter((x) => !Data.includes(x.value));
      this.isClassifyDia = true;
    },
  },
  mounted() {
    if(this.$route.query.id) {
     this.select_classify = Number(this.$route.query.id)
     this.ispublic = 1
    }else {
    this.select_classify = sessionStorage.getItem('myChartOpt')
      ? Number(sessionStorage.getItem('myChartOpt'))
      : '';
    this.ispublic=sessionStorage.getItem('myChartIspublic')? Number(sessionStorage.getItem('myChartIspublic')): '';
    }
    this.getClassify();
    this.getPublicClassify();
  },
};
</script>
<style lang="scss">
.mychart_container {
  position: relative;
  .right-item-box {
    display:flex;
    align-items: center;
    img {
      width: 16px;
    }
    .el-dropdown-link-img {
      width: 18px;
      cursor: pointer;
    }
  }
  .right-content {
    position: fixed;
    left: 40%;
    top: 20%;
    background: #fff;
    padding: 6px 0;
    border: 1px solid #999;
    box-shadow: 0 1px 4px #999;
    z-index: 2;
    li {
      padding: 5px 60px;
      margin: 5px 0;
      color: #333;
      &:hover {
        background: #ddd;
        cursor: pointer;
      }
    }
  }
  .flip-list-move {
    transition: transform 0.4s;
  }
  .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
    background-color: #409eff !important;
    border-color: #409eff;
  }
  .el-checkbox__input.is-disabled.is-indeterminate .el-checkbox__inner {
    background-color: #409eff !important;
    border-color: #409eff;
  }
  .el-card .el-card__header {
    padding: 14px 20px;
  }
  .slide-icon {
    padding: 20px 0;
    /* display: block; */
    box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 99;
    &:hover {
      background-color: rgba(0, 0, 0, 0.05);
    }
    &.slide-left {
      right: 0;
    }
    &.slide-right {
      left: -30px;
    }
  }
  .el-icon-refresh {
    font-size: 17px;
    margin-left: 5px;
    cursor: pointer;
  }
  display: flex;
  div::-webkit-scrollbar {
    width: 5px !important;
  }

  .main-left {
    width: 300px;
    min-width: 300px;
    background: #fff;
    margin-right: 20px;
    border: 1px solid #ececec;
    border-radius: 4px;
    box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.05);
    min-height: calc(100vh - 113px);
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    .left-top {
      padding: 30px 20px 15px;
      .add-cont {
        cursor: pointer;
        font-size: 15px;
        color: #409eff;
      }
    }
    .left-bottom {
      padding: 15px 0 30px;
      overflow: auto;
      max-height: calc(100vh - 290px);
      position: relative;
      .classify-item {
        padding: 10px 30px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        /* &:hover {
          background: #e0eefd;
          color: #409eff;
        } */
        &.act {
          background: #e0eefd;
          color: #409eff;
        }
      }
      .classify-type {
        margin-bottom: 8px;
        padding-left: 15px;
      }
      .public-classify {
        margin-bottom: 20px;
        /* .public-ul {
        } */
      }
    }
    .noclassify {
      margin: 50px 0;
      display: flex;
      align-items: center;
      justify-content: center;
      color: #409eff;
      font-size: 16px;
      cursor: pointer;
    }
    .move-btn {
      height: 100%;
      width: 4px;
      /* opacity: 0; */
      position: absolute;
      right: 0px;
      top: 0;
      z-index: 99;
      &:hover {
        cursor: col-resize;
      }
    }
  }
  .main-right {
    width: 80%;
    position: relative;
    .mx-datepicker {
      width: 220px !important;
    }
    .nodata {
      height: calc(100vh - 240px);
      text-align: center;
      font-size: 16px;
      color: #666;
      .sharer {
        color: #333;
        font-size: 14px;
        position: absolute;
        right: 0;
        top: 0;
      }
    }
    /* =================== */
    .chart-min-cont {
      background: #fff;
      border: 1px solid #ececec;
      height: calc(100vh - 118px);
      overflow: auto;
      /* overflow: hidden; */
      border-radius: 4px;
      box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.05);
      .cont-top {
        padding: 12px 30px;
        border-bottom: 1px solid #ececec;
        display: flex;
        justify-content: space-between;
        align-items: center;
        box-shadow: 0px 3px 6px rgba(167, 167, 167, 0.09);
        .top-left {
          .year-btn {
            font-size: 14px;
            margin-right: 5px;
            margin-bottom: 5px;
          }
          .btn-sty {
            font-size: 16px;
            padding: 10px;
            border: 1px solid #409eff;
          }
        }
        .top-right {
          .span-item {
            font-size: 16px;
            color: #409eff;
            cursor: pointer;
            &:hover {
              text-decoration: underline;
            }
            .el-icon-collection,
            .el-icon-document-copy {
              color: #409eff;
            }
          }
        }
      }
      .cont-bottom {
        padding: 30px;
        /* height: calc(100vh - 250px);
				overflow: auto; */
        .el-input__inner {
          height: 27px;
          line-height: 27px;
          padding: 0 4px;
        }
        .el-input-number .el-input__inner {
          padding: 0 34px 0 4px;
        }
        .el-color-picker--mini .el-color-picker__trigger {
          width: 60px;
          height: 25px;
          padding: 0;
        }
        .el-color-picker--mini .el-color-picker__mask {
          width: 60px;
          height: 25px;
        }
        .el-table__expanded-cell {
          padding: 20px 26px;
        }
        .highcharts-range-selector-group {
          display: none;
          .highcharts-input-group {
            display: none;
          }
        }
        .highcharts-axis-title {
          display: block;
        }
        .calendar-cont {
          display: block;
          margin: 10px auto 0;
          text-align: center;
        }
        /* =================== */
        .chart-show-cont {
          /* border: 1px solid #c9c9c9; */
          margin-bottom: 15px;
          /* padding: 26px 120px 35px; */
          padding: 0 120px 20px;
          position: relative;
          .chart-title {
            font-size: 16px;
            font-weight: normal;
            text-align: center;
            margin-bottom: 10px;
          }
          .chart-author {
            font-size: 14px;
            color: #333;
            position: absolute;
            bottom: 20px;
            right: 38px;
          }
          .chartWrapper {
            position: relative;
            .range-cont {
              position: absolute;
              top: 13%;
              .min-data-input {
                width: 70px;
                display: block;
                margin-top: 354px;
              }
              &.left {
                left: -80px;
              }
              &.right {
                right: -80px;
              }
            }
          }
        }
        .options-cont {
          display: flex;
          flex-wrap: wrap;
          justify-content: space-between;
        }
      }
    }
  }

  .drawImg {
    position: absolute;
    top: -999px;
    z-index: -100;
  }

  /* ===================== */
  .chart-public-cont {
    color: #333;
    .el-card .el-card__header,
    .el-card__body {
      padding: 10px;
    }
    .cont-top {
      display: flex;
      justify-content: space-between;
    }
    .chart-public-list {
      margin-top: 10px;
      height: calc(100vh - 143px);
      overflow: hidden;
      overflow-y: auto;
      .drag-cont {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
      }
      .dragShdow {
        box-shadow: 0 1px 8px rgba(64, 158, 255, 0.8);
        opacity: 0.5;
      }
      .public-chart-item {
        .item-top {
          display: flex;
          justify-content: space-between;
          align-items: center;
          font-size: 16px;
          font-weight: 600;
          position: relative;
        }
        .chart-img {
          width: 100%;
          height: 230px;
          object-fit: fill !important;
          cursor: pointer;
        }
        .item-bottom {
          margin-top: 10px;
          display: flex;
          justify-content: space-between;
          color: #666;
          font-size: 12px;
          .join_txt {
            color: #f00;
            cursor: pointer;
            &.move_txt {
              color: #409eff;
            }
          }
        }
      }
    }
  }  
}
.el-dropdown-menu-item-chat {
    display: flex !important;
    align-items: center !important;
     img {
      width: 16px;
      margin-right: 8px;
    }
    &:hover {
      background-color: #F5F7FA  !important;
      color: #606266 !important;
    }
  }
  .el-dropdown-menu .el-dropdown-menu-item-chat-act {
      // background-color: #ecf5ff !important;
      color: #66b1ff !important;
 }
</style>
