<template>
  <div>
    <el-tabs v-model="activeName" @tab-click="switchTab">
      <el-tab-pane class="pt10" label="活动类别管理" name="first">
        <div>
          <el-button type="primary">导入</el-button>
          <el-button type="primary">导出</el-button>
          <el-button type="primary">添加</el-button>
          <el-button type="danger">删除</el-button>
        </div>
        <el-table
          :data="firstTable"
          v-loading="loading"
          tooltip-effect="dark"
          class="mt20"
          style="width: 100%"
        >
          <el-table-column type="selection" align="center" width="55">
          </el-table-column>
          <el-table-column
            label="分类编码"
            align="left"
            prop="flbm"
            width="150"
          ></el-table-column>
          <el-table-column
            label="分类名称"
            width="150"
            prop="flmc"
          ></el-table-column>
          <el-table-column
            label="审核人"
            width="150"
            prop="shr"
          ></el-table-column>
          <el-table-column label="是否启用" prop="sfqy" width="100">
          </el-table-column>
          <el-table-column label="操作" width="auto">
            <template slot-scope="scope">
              <el-button type="text" @click="">编辑 </el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane class="pt10" label="活动列表" name="second">
        <el-form :inline="true" :model="secondForm">
          <el-form-item class="mr10" label="班级：">
            <el-select v-model="secondForm.grade" placeholder="请选择班级">
              <el-option
                v-for="item in gradeList"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="mr10" label="类别：">
            <el-select v-model="secondForm.type" placeholder="请选择类别">
              <el-option
                v-for="item in typeList"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="mr10" label="活动时间：">
            <el-date-picker
              style="width: 100%"
              v-model="secondForm.time"
              type="date"
              placeholder="请选择日期"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item class="mr10" label="活动名称：">
            <el-input
              v-model="secondForm.title"
              placeholder="输入活动名称"
            ></el-input>
          </el-form-item>
          <el-button type="primary">搜索</el-button>
        </el-form>
        <div>
          <el-button type="primary">发起活动</el-button>
          <el-button type="primary">导出</el-button>
          <el-button type="danger">删除</el-button>
        </div>
        <el-table
          :data="secondTable"
          tooltip-effect="dark"
          class="mt20"
          style="width: 100%"
        >
          <el-table-column type="selection" align="center" width="55">
          </el-table-column>
          <el-table-column
            label="班级"
            align="left"
            prop="bj"
            width="200"
          ></el-table-column>
          <el-table-column label="活动名称" width="auto">
            <template slot-scope="scope">
              <h3 class="font-size-14 color-2 hand">{{ scope.row.hdmc }}</h3>
            </template>
          </el-table-column>
          <el-table-column label="类别" width="100" prop="lb"></el-table-column>
          <el-table-column label="活动时间" prop="hdsj" width="200">
          </el-table-column>
          <el-table-column label="创建人" prop="cjr" width="120">
          </el-table-column>
          <el-table-column label="审核人" prop="shr" width="120">
          </el-table-column>
          <el-table-column label="活动状态" width="120">
            <template slot-scope="scope">
              <span v-if="scope.row.hdzt == 1" class="color-6">未审核</span>
              <span v-if="scope.row.hdzt == 2" class="text-green">进行中</span>
              <span v-if="scope.row.hdzt == 3" class="text-red">已结束</span>
            </template>
          </el-table-column>
          <el-table-column label="活动地点" prop="hddd" width="auto">
          </el-table-column>
          <el-table-column label="操作" width="200">
            <template slot-scope="scope">
              <el-button type="text" @click="">报名 </el-button>
              <el-button type="text" @click="">审核 </el-button>
              <el-button type="text" @click="">编辑 </el-button>
              <el-button type="text" @click="">评价 </el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane class="pt10" label="已报名列表" name="third">
        <el-form :inline="true" :model="secondForm">
          <el-form-item class="mr10" label="类别：">
            <el-select v-model="secondForm.type" placeholder="请选择类别">
              <el-option
                v-for="item in typeList"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="mr10" label="活动时间：">
            <el-date-picker
              style="width: 100%"
              v-model="secondForm.time"
              type="date"
              placeholder="请选择日期"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item class="mr10" label="活动名称：">
            <el-input
              v-model="secondForm.title"
              placeholder="输入活动名称"
            ></el-input>
          </el-form-item>
          <el-button type="primary">搜索</el-button>
        </el-form>
        <div>
          <el-button type="primary">导出</el-button>
          <el-button type="danger">删除</el-button>
        </div>
        <el-table
          :data="thirdTable"
          tooltip-effect="dark"
          class="mt20"
          style="width: 100%"
        >
          <el-table-column type="selection" align="center" width="55">
          </el-table-column>
          <el-table-column
            label="班级"
            align="left"
            prop="bj"
            width="200"
          ></el-table-column>
          <el-table-column label="活动名称" width="auto">
            <template slot-scope="scope">
              <h3 class="font-size-14 color-2 hand">{{ scope.row.hdmc }}</h3>
            </template>
          </el-table-column>
          <el-table-column label="类别" width="100" prop="lb"></el-table-column>
          <el-table-column label="活动时间" prop="hdsj" width="200">
          </el-table-column>
          <el-table-column label="创建人" prop="cjr" width="120">
          </el-table-column>
          <el-table-column label="审核人" prop="shr" width="120">
          </el-table-column>
          <el-table-column label="活动状态" width="120">
            <template slot-scope="scope">
              <span v-if="scope.row.hdzt == 1" class="color-6">未审核</span>
              <span v-if="scope.row.hdzt == 2" class="text-green">进行中</span>
              <span v-if="scope.row.hdzt == 3" class="text-red">已结束</span>
            </template>
          </el-table-column>
          <el-table-column label="活动地点" prop="hddd" width="auto">
          </el-table-column>
          <el-table-column label="得分" width="150">
            <template slot-scope="scope">
              <el-rate
                v-if="scope.row.hdzt != 1"
                v-model="scope.row.score"
                disabled
              >
              </el-rate>
              <div v-else>- -</div>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane class="pt10" label="学生得分列表" name="fourth">
        <el-form :inline="true" :model="fourthForm">
          <el-form-item class="mr10" label="学生姓名：">
            <el-input
              v-model="fourthForm.xsxm"
              placeholder="请输入学生姓名"
            ></el-input>
          </el-form-item>
          <el-form-item class="mr10" label="学籍号：">
            <el-input
              v-model="fourthForm.xsxh"
              placeholder="输入学籍号"
            ></el-input>
          </el-form-item>
          <el-form-item class="mr10" label="手机号码：">
            <el-input
              v-model="fourthForm.sjhm"
              placeholder="输入手机号码"
            ></el-input>
          </el-form-item>
          <el-form-item class="mr10" label="活动名称：">
            <el-input
              v-model="fourthForm.hdmc"
              placeholder="输入活动名称"
            ></el-input>
          </el-form-item>
          <el-button type="primary">搜索</el-button>
        </el-form>
        <div>
          <el-button type="primary">录入</el-button>
          <el-button type="primary">导出</el-button>
          <el-button type="danger">删除</el-button>
        </div>
        <el-table
          :data="fourthTable"
          tooltip-effect="dark"
          class="mt20"
          style="width: 100%"
        >
          <el-table-column type="selection" align="center" width="55">
          </el-table-column>
          <el-table-column
            label="活动名称"
            align="left"
            prop="hdmc"
            width="auto"
          ></el-table-column>
          <el-table-column
            label="学生姓名"
            width="200"
            prop="xsxm"
          ></el-table-column>
          <el-table-column label="学籍号" prop="xsxh" width="200">
          </el-table-column>
          <el-table-column label="手机号码" prop="sjhm" width="200">
          </el-table-column>
          <el-table-column label="得分" width="150">
            <template slot-scope="scope">
              <el-rate
                v-if="scope.row.hdzt != 1"
                v-model="scope.row.score"
                disabled
              >
              </el-rate>
              <div v-else>- -</div>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>
    <footer
      class="flex-item-none"
      style="display: flex; justify-content: flex-end; margin-top: 30px"
    >
      <el-pagination
        background
        layout="total,prev, pager, next"
        :page-size="limit"
        :total="total"
        :current-page.sync="cur_page"
        @current-change="handleCurrentChange"
      ></el-pagination>
    </footer>
  </div>
</template>

<script>
import { hdlb_list } from "./api";
export default {
  name: "index",
  data() {
    return {
      activeName: "first",
      firstTable: [],
      limit: 10,
      total: 0,
      loading: false,
      cur_page: 1,
      secondForm: {
        grade: "",
        type: "",
        title: "",
        time: "",
      },
      gradeList: [
        {
          label: "六年级一班",
          value: 1,
        },
        {
          label: "五年级一班",
          value: 2,
        },
        {
          label: "四年级一班",
          value: 3,
        },
        {
          label: "三年级一班",
          value: 4,
        },
      ],
      typeList: [
        {
          label: "体育",
          value: 1,
        },
        {
          label: "文化",
          value: 2,
        },
        {
          label: "创业",
          value: 3,
        },
        {
          label: "学术",
          value: 4,
        },
      ],
      secondTable: [
        {
          id: 1,
          bj: "六年级一班",
          hdmc: "足球联赛",
          lb: "体育",
          hdsj: "2022-01-21～2022-01-22",
          cjr: "田景",
          shr: "封副",
          hdzt: "1",
          hddd: "操场1001",
        },
        {
          id: 1,
          bj: "六年级一班",
          hdmc: "足球联赛",
          lb: "体育",
          hdsj: "2022-01-21～2022-01-22",
          cjr: "田景",
          shr: "封副",
          hdzt: "2",
          hddd: "操场1001",
        },
        {
          id: 3,
          bj: "六年级一班",
          hdmc: "足球联赛",
          lb: "体育",
          hdsj: "2022-01-21～2022-01-22",
          cjr: "田景",
          shr: "封副",
          hdzt: "3",
          hddd: "操场1001",
        },
        {
          id: 4,
          bj: "六年级一班",
          hdmc: "足球联赛",
          lb: "体育",
          hdsj: "2022-01-21～2022-01-22",
          cjr: "田景",
          shr: "封副",
          hdzt: "2",
          hddd: "操场1001",
        },
        {
          bj: "六年级一班",
          hdmc: "足球联赛",
          lb: "体育",
          hdsj: "2022-01-21～2022-01-22",
          cjr: "田景",
          shr: "封副",
          hdzt: "1",
          hddd: "操场1001",
        },
      ],
      thirdTable: [
        {
          id: 1,
          bj: "六年级一班",
          hdmc: "足球联赛",
          lb: "体育",
          hdsj: "2022-01-21～2022-01-22",
          cjr: "田景",
          shr: "封副",
          hdzt: "1",
          hddd: "操场1001",
          score: 3,
        },
        {
          id: 1,
          bj: "六年级一班",
          hdmc: "足球联赛",
          lb: "体育",
          hdsj: "2022-01-21～2022-01-22",
          cjr: "田景",
          shr: "封副",
          hdzt: "2",
          hddd: "操场1001",
          score: 4,
        },
        {
          id: 3,
          bj: "六年级一班",
          hdmc: "足球联赛",
          lb: "体育",
          hdsj: "2022-01-21～2022-01-22",
          cjr: "田景",
          shr: "封副",
          hdzt: "3",
          hddd: "多媒体1031室",
          score: 2,
        },
        {
          id: 4,
          bj: "六年级一班",
          hdmc: "足球联赛",
          lb: "体育",
          hdsj: "2022-01-21～2022-01-22",
          cjr: "田景",
          shr: "封副",
          hdzt: "2",
          hddd: "操场1001",
          score: 3,
        },
        {
          bj: "六年级一班",
          hdmc: "足球联赛",
          lb: "体育",
          hdsj: "2022-01-21～2022-01-22",
          cjr: "田景",
          shr: "封副",
          hdzt: "1",
          hddd: "操场1001",
          score: 5,
        },
      ],
      fourthForm: {
        xsxm: "",
        xsxh: "",
        sjhm: "",
        hdmc: "",
      },
      fourthTable: [
        {
          id: 1,
          hdmc: "足球联赛",
          xsxm: "田静",
          xsxh: "27645464556",
          sjhm: "13605998421",
          score: 3,
        },
        {
          id: 1,
          hdmc: "足球联赛",
          xsxm: "田静",
          xsxh: "27645464556",
          sjhm: "13605998421",
          score: 5,
        },
        {
          id: 3,
          hdmc: "足球联赛",
          xsxm: "田静",
          xsxh: "27645464556",
          sjhm: "13605998421",
          score: 2,
        },
        {
          id: 4,
          hdmc: "足球联赛",
          xsxm: "田静",
          xsxh: "27645464556",
          sjhm: "13605998421",
          score: 3,
        },
        {
          hdmc: "足球联赛",
          xsxm: "田静",
          xsxh: "27645464556",
          sjhm: "13605998421",
          score: 4,
        },
      ],
    };
  },
  methods: {
    switchTab() {
      console.log(this.activeName, 99);
      switch (this.activeName) {
        case "first":
          this.getActivityType();
          break;
      }
    },
    handleCurrentChange(val) {
      this.cur_page = val;
    },
    getActivityType() {
      this.loading = true;
      let data = {
        page: this.page,
        limit: this.limit,
      };
      hdlb_list(data).then((res) => {
        if (res.code == 1) {
          this.loading = false;
          this.firstTable = res.data.page_data;
          this.cur_page = Number(res.data.page_now);
          this.total = Number(res.data.total_rows);
        }
      });
    },
  },
  mounted() {
    this.getActivityType();
  },
};
</script>

<style scoped>
</style>