<template>
  <div class="integration">
    <div class="integration__head flex">
      <div class="flex-wrap integration__head__uls">
        <div class="list">
          <el-select v-model="total" size="small" clearable placeholder="全部接口">
            <el-option v-for="item in totalData" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </div>
        <div class="list">
          <el-select v-model="source" size="small" clearable placeholder="源数据">
            <el-option v-for="item in sourceData" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </div>
        <div class="list">
          <el-select v-model="target" size="small" clearable placeholder="目标数据">
            <el-option v-for="item in targetData" :key="item.value" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="integration__head__btns flex-wrap">
        <el-button style="padding:0;border: 0;" size="small">
          <router-link to="/integration/interfaceLog">
            <img src="../../../assets/integr/ic_warning.png" alt="" srcset="">
          </router-link>
        </el-button>
        <el-button size="small" type="primary" @click="handleButtonClick(1)">新增接口</el-button>
        <el-button size="small" type="primary">新增源数据</el-button>
        <el-button size="small" type="primary">新增目标数据</el-button>
      </div>
    </div>
    <div class="integration__cont">
      <div class="integration__cont__map">
        <div v-if="flag" class="integration__cont__map__box">
          <div class="acquisitionError">
            <span class="icon"></span>
            <span class="txt">采集错误</span>
          </div>
          <div class="parsingError">
            <span class="icon"></span>
            <span class="txt">解析错误</span>
          </div>
          <div class="saveError">
            <span class="icon"></span>
            <span class="txt">存储错误</span>
          </div>
        </div>
        <!--桑葚图-->
        <sankey-chart v-if="flag" />
        <graph-chart v-else />
      </div>
    </div>
  </div>
</template>
{
<script>
import sankeyChart from './sankeyChart.vue'
import graphChart from './graphChart.vue'
export default {
  name: 'Integration',
  components: { sankeyChart, graphChart },
  data () {
    return {
      totalData: [{
        value: '选项1',
        label: '黄金糕'
      }, {
        value: '选项2',
        label: '双皮奶'
      }],
      sourceData: [{
        value: '选项1',
        label: '黄金糕'
      }, {
        value: '选项2',
        label: '双皮奶'
      }],
      targetData: [{
        value: '选项1',
        label: '黄金糕'
      }, {
        value: '选项2',
        label: '双皮奶'
      }],
      total: '',
      source: '',
      target: '',
      flag: false
    }
  },
  methods: {
    handleButtonClick (num) {
      switch (num) {
        case 1:
          this.$router.push('/integration/interfaceEdit')
          break
        default:
          break
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.integration {
  padding: 16px 46px 24px 24px;
  &__head {
    height: 32px;
    line-height: 32px;
    margin-bottom: 16px;
    &__uls {
      .list {
        width: 144px;
        margin-right: 8px;
        &:last-child {
          margin-right: 0;
        }
      }
    }
  }
  &__cont {
    height: calc(100vh - 170px);
    &__map {
      height: 100%;
      padding: 24px;
      background-color: #fff;
      border-radius: 4px;
      &__box {
        position: relative;
        height: 40px;
        > div {
          position: absolute;
          .icon {
            width: 20px;
            height: 20px;
            background-color: red;
            display: inline-block;
            vertical-align: middle;
            margin-right: 5px;
          }
          .txt {
            font-size: 18px;
            font-weight: 800;
            color: #666666;
            margin-top: -2px;
          }
        }
        .acquisitionError {
          left: 24.7%;
        }
        .parsingError {
          left: 61.8%;
        }
        .saveError {
          left: 86.4%;
        }
      }
      &__cont {
        height: calc(100% - 50px);
      }
    }
  }
}
</style>