 <!--  -->
<template>
  <div class="m-container">
    <h2>
      <div class="squrt"></div>
      乐团展演列表
    </h2>
    <div class="m-core">
      <save-form
        :inline="true"
        ref="searchForm"
        :model="searchForm"
        @submit="search"
        @reset="onReSet"
      >
        <el-form-item prop="search">
          <el-input
            v-model.trim="searchForm.search"
            clearable
            @keyup.enter.native="search"
            placeholder="乐团名称、编号"
          ></el-input>
        </el-form-item>

        <el-form-item prop="organId">
          <el-select
            class="multiple"
            filterable
            v-model.trim="searchForm.organId"
            clearable
            placeholder="请选择分部"
          >
            <el-option
              v-for="(item, index) in selects.branchs"
              :key="index"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item prop="year">
          <el-date-picker
            style="width: 180px !important"
            v-model="searchForm.year"
            type="year"
            value-format="yyyy"
            placeholder="选择年份"
            :clearable="false"
            @change="changeYear"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item prop="term">
          <el-select
            :disabled="!searchForm.year"
            class="multiple"
            filterable
            style="width: 180px !important"
            v-model.trim="searchForm.term"
            placeholder="请选择学期"
            @change="changeTerm"
          >
            <el-option value="0" label="上学期"></el-option>
            <el-option value="1" label="下学期"></el-option>
          </el-select>
        </el-form-item> -->

        <el-form-item>
          <el-button native-type="submit" type="primary">搜索</el-button>
          <el-button native-type="reset" type="danger">重置</el-button>
        </el-form-item>
      </save-form>
      <div class="tableWrap">
        <el-table
          style="width: 100%"
          :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
          :data="tableList"
        >
          <el-table-column
            align="center"
            prop="organName"
            label="所属分部"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="musicGroupName"
            label="乐团名称"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="musicGroupId"
            label="乐团编号"
          ></el-table-column>
          <el-table-column
            align="center"
            prop="name"
            label="展演名称"
          ></el-table-column>
          <el-table-column align="center" prop="startTime" label="预计时间">
            <template slot-scope="scope">
              <div>{{ scope.row.startTime | dayjsFormat}}</div>
            </template>
          </el-table-column>
          <el-table-column align="center" prop="subDay" label="剩余天数">
          </el-table-column>
          <el-table-column
            align="center"
            prop="musicScoreName"
            label="展演曲目"
          >
          </el-table-column>
        </el-table>
        <pagination
          sync
          :total.sync="rules.total"
          :page.sync="rules.page"
          :limit.sync="rules.limit"
          :page-sizes="rules.page_size"
          @pagination="getList"
        />
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import { getToken } from "@/utils/auth";
import pagination from "@/components/Pagination/index";
import quiteTeam from "@/views/teamDetail/components/modals/quite-team";
import { StudentQuit } from "@/api/buildTeam";
import load from "@/utils/loading";
import { getMusicGroupPerformance } from "./api";
import visit from "@/views/withdrawal-application/modals/visit";
import { getTimes } from "@/utils";
export default {
  components: { pagination, quiteTeam, visit },
  data() {
    return {
      searchForm: {
        search: null,
        organId: null,
        year: "",
        term: "",
      },

      tableList: [],
      organList: [],
      rules: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 0, // 总条数
        page_size: [10, 20, 40, 50], // 选择限制显示条数
      },
    };
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    // 获取分部
    this.$store.dispatch("setBranchs");
    this.init();
  },
  methods: {
    init() {
      this.getList();
    },
    async getList() {
      // 设置时间

      try {
        const res = await getMusicGroupPerformance({
          ...this.searchForm,
          page: this.rules.page,
          rows: this.rules.limit,
        });
        this.tableList = res.data.rows;
        this.rules.total = res.data.total;
      } catch (e) {
        console.log(e);
      }
    },
    search() {
      this.rules.page = 1;
      this.getList();
    },
    onReSet() {
      this.$refs["searchForm"].resetFields();
      this.search();
    },
  },
  watch: {},
};
</script>
<style lang='scss' scoped>
</style>
