<template>

  <div   class="container">
    <el-row>
      <div class="tool-bar">
        <div>
          <span class="title-name">仪表盘标题</span>
          <span>解释信息</span>
        </div>
        <div>
          <el-button class="miniSuccess" @click="control_edit()">编辑</el-button>
          <el-button class="successBorder" @click="handleLinkChart">
            添加图表
          </el-button>
        </div>
      
    </div>
    </el-row>

    <el-row>
      <div>
        <draggable v-model="boardList" group="itxst"   animation="300" :group="{name: 'dashboard',pull: true}" @start="onStart" @end="onEnd">
          <transition-group>

          <el-card class="box-card board-card" key="1" v-for="item in boardList">
            <div slot="header" class="clearfix">
              <span>{{item.title}}</span>
        

              <div  style="float: right; padding: 3px 0;display:inline-block;">
                <i  class="el-icon-edit" style="color:#009C69;cursor:pointer;" />
                <i  class="el-icon-delete" style="color:#009C69;cursor:pointer;"  />

              </div>

            </div>
            <div  class="text item"> 
              图表内容
            </div>
          </el-card>
                    
                        
          </transition-group>
        </draggable>

      </div>
    </el-row>

    <el-row>

    </el-row>

    

    


    <el-dialog  title="我的图表" :visible.sync="showChartList">
      <!-- <el-button type="primary" size="mini" @click="$router.push({ name: 'ChartPanel', params: { id: 'create' , isEdit: 'edit'}})">
        创建新的图表
      </el-button> -->

      <el-button class="save" style="margin-bottom: 10px;" @click="jumpCreate()"> 创建新的图表 </el-button>

      <el-table :data="myChartList" border>
        <el-table-column :label="$t('common.name')" width="200" prop="chart_name" />
        <el-table-column :label="$t('common.desc')" prop="desc" />
        <el-table-column :label="$t('common.operation')" align="center">
          <template slot-scope="scope">
            <el-button class="miniPrimary" :disabled="isExisted(scope.row)" @click="linkChart(scope.row)">添加</el-button>
            <el-button size="mini" type="warning" style="padding: 6px 10px !important;font-size:14px;" @click="jumpEdit2(scope.row)">  编辑 </el-button>

          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer" style="bottom: 10px;">
        <el-button class="cancelClose1" @click="showChartList = false">关闭</el-button>
      </div>
    </el-dialog>
 
    
  </div>

</template>

<script>
import draggable from 'vuedraggable'
 
import { GetDataByName } from '@/api/common'
import Cookies from 'js-cookie'
 
export default {
  name: 'Addboard2',
  components: {  draggable },
  data() {
    return {
      isRoleEdit: [],

      boardList: [
        {
          title:'图表1',boardId:1,boardtype:'line',
          boardtext:[]
        },
        {title:'图表2'},
        {title:'图表3'},
        {title:'图表3'},
        {title:'图表3'},

        {title:'图表3'},
        {title:'图表3'},
       ],

       myChartList: [],
      showChartList: false,
      chartLoading: {},



      isEdit: 'view',
      dashboardList: [],
      currentDashboard: undefined,
      editDialogVisible: false,
      dbObj: {},
      loading: false,
      isCollapse: false,
      did: undefined,
      isTitle: '2',
      editBtn: false,
      control_btn: '编辑',
      control_btn_l: false,

 

    }
  },

  created() {
    // console.log('this.$route.params.id', this.$route.params.id)
    // const isEdit = this.$route.params.isEdit

    // this.isEdit = isEdit
 
    this.getList()
  },

  methods: {




       onStart(){
      console.log(2222)
    },
    onEnd(){
      console.log(this.boardList)

  
    },
     

    getList() {
      this.loading = true

      // if (this.$route.params.id) {
      //   this.did = this.$route.params.id
      // } else {
      //   this.did = this.did
      // }

     
    },
    //添加图表
    handleLinkChart() {
      var send_data = {
        name: 'getChartListV2',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {
          pastureid: Cookies.get('pastureid'),
          empid: Cookies.get('employeid')
        }
      }
      GetDataByName(send_data).then(response => {
        console.log('table数据', response.data.list)
        if (response.data.list !== null) {
          this.myChartList = response.data.list
          this.showChartList = true
        } else {
          this.myChartList = []
          this.showChartList = true
        }
      })
    },
   
  }
}
</script>
<style scoped>
.board{
  width:300px;height:300px;border:1px soild #333;display:inline-block;background: #2ed1f9;padding: 5px 5px;margin-right: 15px;margin-bottom: 15px;
}


.tool-bar {
  display: block; border-top: none;
  height: 45px;
  line-height: 45px;
  color: #303133;
  padding: 0 10px;
  position: relative;
 
}
 .title-name {
    font-size: 12px;
    font-weight: 600;
    color: #909399;
    margin-left: 0;
  }
  /* span {
    color: #c0c4cc;
    font-size: 12px;
    margin-left: 10px;
  }

  .text {
    font-size: 14px;
  }

  .item {
    margin-bottom: 18px;
  } */

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }

  .board-card {
    width: 250px;min-height: 100%;
    padding: 20px 10px;
    display: inline-block;
    margin: 0px 0px 20px 20px;
  }
</style>

<style lang="scss" scoped>


</style>
