<template>
  <div style="border: 2px #eef1f2 solid;">
    <div>
      <div style="width: 100%;height: 20px;background-color: #1c84c6;"></div>
      <div style="width:100%;white-space:normal; word-break:break-all;overflow:hidden;padding: 10px;height: 70px;font-weight: 600;font-size: 16px;">
        {{ item.kcmc }} <span v-if="item.szkc == '1'" title="思政课程">⭐</span>
      </div>
    </div>
    <a-divider style="margin: 0px;color: #eef1f2;" />
    <div style="padding: 20px;font-weight: 600;">
      <a-row>
        <a-col :span="16">
          <div style="height: 38px;font-size: 16px;">{{ item.skjs }}</div>
          <div style="font-size: 14px;height: 50px;">{{ item.kkdw }}</div>
        </a-col>
        <a-col :span="8" style="text-align: center;height: 70px;">
          <div style="color: #1c84c6;font-size: 24px;font-weight: 600;">{{ item.xkrs }}</div>
          <div style="font-size: 14px;">选课人数</div>
        </a-col>
        <a-col :span="24" style="margin-top:20px;">
          <div>
            第<span>{{ item.hh }}</span>节
          </div>
        </a-col>
        <a-col :span="24">
          <div style="width:100%;text-align: center;">
            ———线下上课地点———
          </div>
        </a-col>
        <a-col :span="24">
          <div style="height: 60px;">
            {{ item.skdd }}
          </div>
        </a-col>
        <a-col :span="24" >
          <a-row style="text-align: center;" v-if="!isNow(item)">
            <a-col :span="12" style="text-align: center;">
              <a-button type="primary" class="yyyClass" @click="toLivePage(item)" style="color: white;"  :disabled="item.sftkb=='1'">听课</a-button>
            </a-col>
            <a-col :span="12" style="text-align: center;">
              <a-button type="primary" class="yyClass" @click="funpingjia(item)" style="color: white;"  :disabled="item.sftkb=='1'">评价</a-button>
            </a-col>
            <!-- <a-col :span="8">
              <a-button type="primary" class="bcClass" @click="handleBaocuo(item)">报错</a-button>
            </a-col> -->
          </a-row>
          <a-row style="text-align: center;" v-else>
            <!-- <a-col :span="12" style="text-align: center;">
              <a-button type="primary" class="yyyClass" @click="toLivePage(item)" disabled>听课</a-button>
            </a-col> -->
            <a-col :span="24" style="text-align: center;">
              <a-button type="primary" class="yyClass" @click="funpingjia(item)" >评价</a-button>
            </a-col>
          </a-row>

        </a-col>
      </a-row>
    </div>
    <!-- 报错列表 -->
    <KcErrorreportIndexModalPage ref="kcErrorreportIndexModal"></KcErrorreportIndexModalPage>
  </div>
</template>

<script lang="ts" setup>
import { ref,watch,reactive,defineExpose,onMounted,computed } from 'vue';
import dayjs from 'dayjs';
import KcErrorreportIndexModalPage from '/@/views/kc/kcErrorreport/components/KcErrorreportIndexModal.vue'

const kcErrorreportIndexModal = ref();
const props = defineProps({
   data: { type: Object },
});

const item = ref<any>(computed(() => props.data));

const emit = defineEmits(['toLivePage', 'funpingjia']);

function toLivePage(item){
  emit('toLivePage',item);
}

function funpingjia(item){
  emit('funpingjia',item);
}

function isNow(item){
  const jssj = dayjs(item.skrq + " " +item.jssj, 'YYYY-MM-DD hh:mm:ss');
  const dqsj = dayjs(new Date());
  if(jssj.unix() < dqsj.unix()){
    return true;
  }else{
    return false;
  }
}

/**
 * 报错事件
 */
 function handleBaocuo(item) {
  kcErrorreportIndexModal.value.disableSubmit = false;
  kcErrorreportIndexModal.value.add(item);
}

</script>

<style lang="less" scoped>
.yyyClass{
  background: #1c84c6;font-weight: 600;color:#fff;border-radius: 5px;line-height: 23px;
}
.yyClass{
  background-color: #1c84c6;font-weight: 600;color:#fff;border-radius: 5px;line-height: 23px;
}
.bcClass{
  background-color: #1c84c6;font-weight: 600;border-radius: 5px;line-height: 23px;
}
</style>
