<template>
  <div class="sound-container">
    <div class="topMsg">
      <p>当前选择声部数(个）：{{ chioseSoundNum }}</p>
      <p style="margin-left: 30px">计划招生人数(个）：{{ PlannedCount }}</p>
    </div>
    <soundSetCore ref="soundSetCore"
                  @chiosetab="chiosetab"
                  @getBaseInfo="getBaseInfo"
                  @getNumber="getNumber" />
    <div class="btnWrap">
      <div class="PrevBtn"
           @click="goback">上一步</div>
      <!--  v-if="teamStatus != 'teamAudit'" -->
      <div class="submitBtn"
           v-permission="{
          child: 'musicGroup/createGroup',
          parent: '/teamBuild/soundMoney',
        }"
           @click="submitInfo()">
        下一步
      </div>
      <!-- <div
        class="submitBtn"
        @click="submitAudit(1)"
        v-if="teamStatus != 'teamAudit'"
      >
        提交审核
      </div> -->
      <div class="submitBtn"
           @click="approval"
           v-if="teamStatus == 'teamAudit'"
           v-permission="{child: 'musicGroup/auditSuccess', parent: '/teamBuild/teamAudit/soundMoney'}">
        审核通过
      </div>
      <div class="submitBtn"
           @click="refuse"
           v-if="teamStatus == 'teamAudit'"
           v-permission="{child: 'musicGroup/auditFailed', parent: '/teamBuild/teamAudit/soundMoney'}">
        驳回
      </div>
    </div>
  </div>
</template>
<script>
import store from "@/store";
import { formatData } from "@/utils/utils";
import {
  getSubject,
  getDefaultSubject,
  getGoods,
  createTeam,
  getSoundTree,
  findMusicGroupSubjectInfo,
  updateSubjectInfo,
  auditSuccess,
  auditFailed,
  getSubjectGoods,
} from "@/api/buildTeam";
import dayjs from "dayjs";

import soundSetCore from "./soundSetComponents/soundSetCore";

export default {
  components: { soundSetCore },
  data () {
    return {
      topfor: null, // 第一页的数据
      Fsearch: null,
      Frules: null,
      activeSoundList: [],
      chioseSoundNum: 0,
      PlannedCount: 0,
      teamStatus: null,
      teamid: null
    };
  },
  mounted () {
    this.teamid = this.$route.query.id;
    this.teamStatus = this.$route.query.type;
  },
  activated () {
    this.teamid = this.$route.query.id;
    this.teamStatus = this.$route.query.type;
  },
  methods: {
    goback () {
      this.$emit("chiosetab", 0);
    },
    submitInfo () {
      this.$refs.soundSetCore.submitInfo();
    },
    chiosetab (val) {
      this.$emit("chiosetab", val);
    },
    submitAudit (val) {
      this.$refs.soundSetCore.submitInfo(val);
    },
    getNumber (chioseSoundNum, PlannedCount) {
      this.chioseSoundNum = chioseSoundNum;
      this.PlannedCount = PlannedCount;
    },
    getBaseInfo (baseInfo) {
      this.$emit('getBaseInfo', baseInfo)
    },
    approval () {
      this.$confirm(`是否审核通过?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          auditSuccess({ musicGroupId: this.teamid }).then((res) => {
            if (res.code == 200) {
              this.$message.success("审核通过");
              this.$router.push({
                path: "/business/teamDetail",
                query: { search: this.Fsearch, rules: this.Frules },
              });
            }
          });
        })
        .catch(() => { });
    },
    refuse () {
      // auditFailed
      this.$prompt("请输入拒绝原因", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消"
      }).then(({ value }) => {
        //   点击确认  值是value
        if (!value) {
          this.$message.error("请输入驳回原因");
          return;
        } else {
          auditFailed({ musicGroupId: this.teamid, memo: value }).then(res => {
            if (res.code == 200) {
              this.$message.success("已拒绝");
              this.$router.push({
                path: "/business/teamDetail",
                query: { search: this.Fsearch, rules: this.Frules }
              });
            }
          });
        }
      });
    },
  },

  computed: {},
};
</script>
<style lang="scss" scoped>
.topMsg {
  padding: 0 25px;
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  font-size: 14px;
  color: #444;
  margin-bottom: 20px;
}
.soundBtnWrap {
  margin-bottom: 20px;
}
/deep/.el-collapse-item__header {
  background-color: #edeef0;
}
.coreItemTitle {
  background-color: #edeef0;
  height: 46px;
  line-height: 46px;
  padding: 0 20px;
}
.coreItem {
  padding: 25px 0 0;
}
.coreItemRow {
  padding: 0 20px;
  line-height: 50px;
  display: flex;
  flex-direction: row;
  align-items: center;
  p {
    margin-right: 10px;
  }
  .title {
    width: 100px;
    text-align: right;
  }
}
.marginLeft10 {
  margin-left: 10px;
}
/deep/.el-collapse-item__header {
  border-bottom: 1px solid #fff;
}
.btnWrap {
  margin-top: 40px;
  .PrevBtn {
    background-color: #13817a;
    width: 120px;
  }
  .submitBtn {
    background-color: #13817a;
    width: 120px;
  }
}
</style>