<template>
  <div>
    <back-box>
      <template slot="title">
        <span>学校设置</span>
      </template>
      <template slot="btns">
        <el-tooltip effect="dark" content="导入学校名单" placement="bottom">
          <el-button
            type="primary"
            icon="el-icon-upload2"
            size="mini"
            plain
            circle
            @click="diaUp = true"
          ></el-button>
        </el-tooltip>
      </template>
    </back-box>
    <div class="page-content">
      <div class="content-box">
        <i class="el-icon-edit"></i>
        <ul class="school-info">
          <li class="school-item">
            <span class="s1">学校名称：</span>
            <span class="s2">{{ school.title }}</span>
          </li>
          <li class="school-item">
            <span class="s1">授课端管理密码：</span>
            <span class="s2">{{ school.password }}</span>
          </li>
          <li class="school-item">
            <span class="s1">联系人：</span>
            <span class="s2">{{ school.lianxiren }}</span>
          </li>
          <li class="school-item">
            <span class="s1">手机号码：</span>
            <span class="s2">{{ school.phone }}</span>
          </li>
          <li class="school-item">
            <span class="s1">学段：</span>
            <span class="s2">{{ school.xueduan }}</span>
          </li>
          <li class="school-item">
            <span class="s1">所属集团：</span>
            <span class="s2">{{ school.jituan }}</span>
          </li>
        </ul>
        <div class="grade-box">
          <p class="h-title">年级管理</p>
          <ul class="grade-info">
            <li class="grade-item">
              <p class="grade-name">一年级</p>
              <div class="grade-class">
                <p><i class="fa fa-building"></i>班级：10个</p>
                <p><i class="fa fa-book"></i>科目：10个</p>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <el-dialog title="导入学校名单" :visible.sync="diaUp" width="400">
      <up-load id="downDevice" :url="url" fileName="学校名单">
        <p class="down-txt" slot="down">
          通过Excel名单导入学校名单，需要提供设备编码，点击
          <el-link type="danger" @click="downExcel">模板下载</el-link> 。
        </p>
      </up-load>
      <div class="dialog-footer" slot="footer">
        <el-button @click="diaUp = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { downloadFile } from "@/utils";
export default {
  data() {
    return {
      url: "xxx",
      diaUp: false,
      school: {
        title: "长水实验中学",
        password: "123456",
        lianxiren: "张老师",
        phone: "13548645321",
        xueduan: "初中",
        jituan: "长水集团",
      },
    };
  },
  methods: {
    async downExcel() {
      let data = await this.$request.downDevice({
        id: this.id,
      });
      if (data && !data.code) {
        let blob = new Blob([data], {
          type: "application/vnd.ms-excel;charset=utf-8",
        });
        downloadFile(`设备信息.xlsx`, blob);
      } else {
        this.$message.error(data.message);
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.page-content {
  padding: 20px;
  .content-box {
    background: #f8f8f8;
    border-radius: 16px;
    position: relative;
    .el-icon-edit {
      position: absolute;
      top: 12px;
      right: 12px;
      padding:5px;
      font-size:18px;
      cursor: pointer;
      &:hover{
        color:#36f
      }
    }
  }
  .school-info {
    display: flex;
    flex-wrap: wrap;
    padding: 16px 0;
    border-bottom:.5px solid #f2f2f2;
    .school-item {
      width: 50%;
      line-height: 48px;
      padding-left: 100px;
      display: flex;
      box-sizing: border-box;
      .s1 {
        width: 160px;
        font-size: 15px;
        color: #888;
      }
      .s2 {
        flex: 1;
      }
    }
  }
  .grade-box {
    padding: 20px;
    .grade-info{
      display: flex;
      flex-wrap:wrap;
      padding:20px;
      .grade-item{
        width:300px;
        margin-right:50px;
        margin-bottom:40px;
        box-sizing: border-box;
        padding:12px 16px;
        border-radius:10px;
        box-shadow: 1px 1px 3px #888;
      }
      .grade-name{
        font-size:16px;
        font-weight: bold;
        line-height: 18px;
        padding-bottom:12px;
      }
      .grade-class{
        display: flex;
        justify-content: space-between;
        font-size:15px;
        padding-right:20px;
        .fa{
          font-size:18px;
          margin-right:5px;
          color:#a4a4a4
        }
        .fa-book{
           font-size:20px;
        }
      }
    }
  }
}
</style>