<template>
  <!-- 全球先进光源 -->
  <div class="wrap">
    <div class="actions">
      <p class="page-name">页面设置/全球先进光源</p>
      <div>
        <el-button type="primary"
                   @click="preview">预览</el-button>
        <el-button @click="save(0)">保存为草稿</el-button>
        <el-button type="primary"
                   @click="save(1)">发布</el-button>
        <el-button @click="back">放弃编辑</el-button>
      </div>
    </div>

    <div class="modules">
      <div class="relative">
        <div class="single-banner">
          <img class="banner-img"
               :src="modules[0].form.pic"
               alt="" />
          <div class="texts">
            <h6 class="banner-title">{{ modules[0].form.title }}</h6>
          </div>
        </div>
        <div class="cover"
             @click="toSet(0)">点击更换banner与链接</div>
      </div>

      <div class="block gray">
        <div class="inner c-wrap">
          <h2 class="b-title wow fadeInUp">{{ modules[1].form.title }}</h2>
          <p class="intro wow fadeInUp"
             data-wow-delay="0.8s">{{ modules[1].form.des }}</p>
          <img class="block-pic br wow fadeInLeft"
               data-wow-delay="0.8s"
               width="100%"
               height="536"
               :src="modules[1].form.pic"
               alt="">
          <div class="cover"
               @click="toSet(1)">点击更换标题、描述、图片与链接</div>
        </div>
      </div>

      <div class="block sources">
        <div class="inner c-wrap">
          <ul class="tabs wow fadeInLeft">
            <li v-for="(item, i) in tabs"
                :class="{active: item.id == active}"
                :key="i"
                @click="tabChange(item.id)">{{ item.name }}</li>
          </ul>
          <div v-if="!active"
               class="c-wrap">
            <table class="table">
              <thead>
                <tr>
                  <th>序号</th>
                  <th>光源名称</th>
                  <th>国家</th>
                  <th>电子束能量（GeV）</th>
                  <th>储存环周长(m)</th>
                  <th>实验站数量</th>
                  <th>代际</th>
                  <th>建成/改造时间</th>
                  <th>发射度(nm.rad)</th>
                  <th>状态</th>
                </tr>
              </thead>
              <template v-if="modules[2].list.length">
                <tr v-for="(item, i) in modules[2].list"
                    :key="i">
                  <td>{{ item.name }}</td>
                  <td>{{ item.country }}</td>
                  <td>{{ item.gev }}</td>
                  <td>{{ item.storage }}</td>
                  <td>{{ item.stations }}</td>
                  <td>{{ item.intergenerational }}</td>
                  <td>{{ item.time }}</td>
                  <td>{{ item.name }}</td>
                  <td>{{ item.emittance }}</td>
                  <td>{{ item.status }}</td>
                </tr>
              </template>
              <tr v-else>
                <td class="none">暂无数据</td>
              </tr>
            </table>
            <div class="cover"
                 @click="toSet(2)">点击更换表格</div>
          </div>
          <div v-else
               class="c-wrap">
            <table class="table">
              <thead>
                <tr>
                  <th>光源名称</th>
                  <th>国家</th>
                  <th>地点</th>
                  <th>加速器技术</th>
                  <th>能量/GeV</th>
                  <th>波长范围/nm</th>
                  <th>重复频率/Hz Repetition rate</th>
                  <th>设施长度/m Overall length</th>
                  <th>线站数量</th>
                  <th>状态</th>
                  <th>出光时间</th>
                </tr>
              </thead>
              <template v-if="modules[3].list.length">
                <tr v-for="(item, i) in modules[3].list"
                    :key="i">
                  <td>{{ item.name }}</td>
                  <td>{{ item.country }}</td>
                  <td>{{ item.address }}</td>
                  <td>{{ item.accelerator }}</td>
                  <td>{{ item.gev }}</td>
                  <td>{{ item.wavelength }}</td>
                  <td>{{ item.repetitive }}</td>
                  <td>{{ item.facility }}</td>
                  <td>{{ item.stations }}</td>
                  <td>{{ item.status }}</td>
                  <td>{{ item.time }}</td>
                </tr>
              </template>
              <tr v-else>
                <td class="none"
                    colspan="11">暂无数据</td>
              </tr>
            </table>
            <div class="cover"
                 @click="toSet(3)">点击更换表格</div>
          </div>
        </div>
      </div>
    </div>

    <Module ref="module"
            :data.sync="curData"
            :visible.sync="diaVisible"
            @moduleSubmit="moduleSubmit" />
  </div>
</template>

<script>
import mixins from '@/mixins/page'
import Modules from '@/const/modules'
export default {
  mixins: [mixins],
  data () {
    return {
      modules: Modules.lightSources,
      active: 0,
      tabs: [
        {
          id: 0,
          name: '同步辐射光源'
        },
        {
          id: 1,
          name: '自由电子激光'
        },
      ]
    }
  },
  mounted () {
    this.$store.commit('user/setCrumbs', [
      {
        name: '站点管理',
        route: '/site'
      },
      {
        name: '内容管理',
        route: '/column'
      },
      {
        name: '栏目管理',
        route: '/column'
      },
      {
        name: '全球先进光源'
      }
    ])
  },
  methods: {
    // tab回调
    tabChange (i) {
      this.active = i
    },
  }
};
</script>

<style lang="scss" scoped>
@import '../../../styles/page/page.scss';
.block {
    padding: 3.15rem 0;
    .inner {
        .b-title {
            font-size: 2.25rem;
            margin-bottom: 2.25rem;
        }
        .intro {
            margin-bottom: 2.25rem;
        }
    }
}
.block-pic {
    transition: 0.3s;
    height: auto;
    &.br {
        border-radius: 270px;
    }
    &:hover {
        transform: scale(1.05);
    }
}
.sources {
    background-color: #fff;
}
.tabs {
    display: flex;
    justify-content: flex-start;
    box-shadow: 0px 2px 10px 0px rgba(223, 223, 223, 0.28);
    li {
        padding: 25px 19px;
        margin: 0 10px;
        font-size: 1.1rem;
        color: #333;
        border-bottom: 4px solid transparent;
        text-shadow: 0px 2px 14px rgba(167, 167, 167, 0.26);
        cursor: pointer;
        &.active {
            color: #1583ff;
            border-bottom-color: #1583ff;
        }
    }
}
.table {
    width: 100%;
    margin-top: 20px;
    border-collapse: collapse;
    th,
    td {
        padding: 10px 10px;
        font-size: 0.9rem;
        text-align: left;
    }
    .none {
        text-align: center;
    }
}
</style>