<template>
  <a-list item-layout="horizontal" :data-source="list" :grid="{ gutter: 16, xs: 2, sm: 4, md: 4, lg: 4, xl: 4, xxl: 4, xxxl: 4 }">
  <!-- <a-list item-layout="horizontal" :data-source="list" :loading="loadingList" :grid="{ column: }"> -->
    <template #renderItem="{ item }">
      <a-list-item>
          <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 }} <template v-if="item.szkc == '1'" title="思政课程">⭐</template>
            </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;font-weight: 700;">{{ item.skjs }}</div>
                <div style="font-size: 14px;font-weight: 700;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;font-weight: 700;">选课人数</div>
              </a-col>

              <a-col :span="24" style="margin-top:0px;font-weight: 700;">
                <div>教师评价：{{ (item.jspjPjf == 0?null:item.jspjPjf) || '未评价' }}</div>
                <div>学生评价：{{ (item.xspjPjf == 0?null:item.xspjPjf) || '未评价' }}</div>
              </a-col>

              <a-col :span="24" style="margin-top:0px;font-weight: 700;">
                <div>
                  第<span>{{ item.hh }}</span>节
                </div>
              </a-col>
              <a-col :span="24">
                <div style="width:100%;text-align: center;font-weight: 700;">
                  ———线下上课地点———
                </div>
              </a-col>
              <a-col :span="24">
                <div style="height: 50px;font-weight: 700;">
                  {{ item.skdd }}
                </div>
              </a-col>
              <a-col :span="24">
                <a-row style="text-align: center;">
                  <a-col :span="12">
                    <a-button type="primary" class="bcClass" @click="openJspjPage(item)" >教师评价</a-button>
                  </a-col>
                  <a-col :span="12">
                    <a-button type="primary" class="bcClass" @click="openXspjPage(item)" >学生评评价</a-button>
                  </a-col>
                </a-row>
              </a-col>
            </a-row>
          </div>
        </div>


          <!-- <div class="wenZiJiaCu fs1d1r">
            <div>课程名称：{{ item.kcmc }}</div>
            <div>授课教师：{{ item.skjs }}</div>
            <div>开课单位：{{ item.kkdw }}</div>
            <div>授课地点：{{ item.skdd }}</div>
            <div>教师评价：{{ item.jspjPjf }}</div>
            <div>学生评价：{{ item.xspjPjf }}</div>

            <div style="text-align: center;margin: 0.5rem 0;">
              <a-row>
                <a-col :xs="{ span: 24 }" :sm="{ span: 12 }" :lg="{ span: 12 }">
                  <a-button type="primary" style="margin: 0.5rem 0;" @click="openJspjPage(item)">教师评价</a-button>
                </a-col>
                <a-col :xs="{ span: 24 }" :sm="{ span: 12 }" :lg="{ span: 12 }">
                  <a-button type="primary" style="margin: 0.5rem 0;" @click="openXspjPage(item)">学生评评价</a-button>
                </a-col>
              </a-row>
            </div>
          </div> -->
      </a-list-item>
    </template>
  </a-list>
  <a-pagination v-model="current" :total="total" show-less-items @change="handlePageChange" v-if="props.flagPage" style="text-align: right;" :hideOnSinglePage="true"/>
  <addModalPage ref="tingKeZuJiAddModal"/>
  <viewModalPage ref="viewModal"/>
  <fwdtModalPage ref="fwdtModal"/>

  <jspjModal ref="jspjModalPage"/>
  <xspjModal ref="xspjModalPage"/>


</template>
<script setup lang="ts">
import { ref, onMounted, watch } from 'vue';
import { TeamOutlined, FormOutlined } from '@ant-design/icons-vue';
import { Pagination } from 'ant-design-vue';
import { getUserId, getSysConfig } from '/@/views/site/utils/index';

import addModalPage from '/@/views/site/tingKeZuJi/components/addModal.vue';
import viewModalPage from '/@/views/site/tingKeZuJi/components/viewModal.vue';
import fwdtModalPage from '/@/views/site/tingKeZuJi/components/fwdtModal.vue';

import jspjModal from './components/jspjModal.vue';
import xspjModal from './components/xspjModal.vue';

import { defHttp } from '/@/utils/http/axios';
// import { tuple } from 'ant-design-vue/lib/_util/type';
enum Api {
  // list = '/kcTingke/kcTingke/findTingKeZuJiBytingketimeAndUserId'
  // list = '/qa/kcEvaluation/queryPkZuJiList'
  list = '/ktgl/kcKetangbiao/fundAllPjjgList'
}

const tingKeZuJiAddModal = ref();
const viewModal = ref();
const fwdtModal = ref();
const jspjModalPage = ref();
const xspjModalPage = ref();

const current = ref<number>(0);
const total = ref<number>(2);
const loadingList = ref<boolean>(false);

const APagination = Pagination;
const emit = defineEmits(['changeParam']);

const props = defineProps({
  queryParam: { type: Object, default: () => ({}) },
  flagPage: { type:Boolean,default:false}
});

/**
 * 列表接口
 * @param params
 */
const listApi = (params) => defHttp.get({ url: Api.list, params });

const list = ref<any>([]);
onMounted(() => {
  init();
});

watch(
  () => props.queryParam,
  (v) => init(),
  {
    deep:true,
    immediate:true,
  }
);


function init() {
  console.log('init');
  loadingList.value = true
  listApi({ jgh: getUserId(), searchByNowXqxn: true, ...props.queryParam }).then(res => {
    list.value = res?.records ?? [];

    total.value = res.total;
    current.value = res.current;
    list.value = res.records
    loadingList.value = false
  });
}

function handlePageChange(record){
  emit('changeParam',record);
  // loadData();
}

function onSearch() {
  init();
}

//教师评价
function openJspjPage(item) {
  jspjModalPage.value.view(item)
}

//学生评价
function openXspjPage(item) {
  xspjModalPage.value.view(item)
}

defineExpose({
  onSearch
});

</script>
<style lang="less" scoped>
.wenZiJuZhong {
  text-align: center;
}
.wenZiJiaCu {
  font-weight: 700;
}
.fs1d1r {
  font-size: 16px;
  min-height: 55.281px;
}
.hand {
 cursor:pointer;
}
.dateAndTime {
  padding-top: 10px;
}

.yyyClass{
  background: #6cafda;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>