<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>
        <a-card>
          <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-card>
        <!-- <a-list-item-meta>
          <template #title>
            <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;">
                <a-button type="primary" style="margin-right: 1rem;" @click="openJspjPage(item)">教师评价</a-button>
                <a-button type="primary" style="margin-right: 1rem;" @click="openXspjPage(item)">学生评评价</a-button>
              </div>

            </div>
          </template>
          <template #description> -->
            <!-- -{{ item }}- -->
            <!-- <div class="wenZiJiaCu">
              <span v-if="item.score" class="hand" style="color: #337ab7;" @click="viewModal.view(item)">已评分：{{ item.score }}分</span>

              <span v-if="item.source != null" class="hand" style="padding-left: .5rem;color: #337ab7;">【</span>
              <span v-if="item.source=='0'" class="hand" style="padding-left: .5rem;color: #337ab7;">课程中心</span>
              <span v-else-if="item.source=='1'" class="hand" style="padding-left: .5rem;color: #337ab7;">老系统</span>
              <span v-else-if="item.source=='2'" class="hand" style="padding-left: .5rem;color: #337ab7;">政务大厅</span>
              <span v-else-if="item.source=='3'" class="hand" style="padding-left: .5rem;color: #337ab7;">纸质评价</span>
              <span v-if="item.source != null" class="hand" style="padding-left: .5rem;color: #337ab7;">--</span>
              <span v-if="item.evaluationver=='1'" class="hand" style="padding-left: .5rem;color: #337ab7;">原始数据</span>
              <span v-else-if="item.evaluationver=='2'" class="hand" style="padding-left: .5rem;color: #337ab7;">线上听课</span>
              <span v-else-if="item.evaluationver=='3'" class="hand" style="padding-left: .5rem;color: #337ab7;">听课记录</span>
              <span v-else-if="item.evaluationver=='4'" class="hand" style="padding-left: .5rem;color: #337ab7;">同行专家</span>
              <span v-if="item.source != null" class="hand" style="padding-left: .5rem;color: #337ab7;">】</span>
            </div> -->
          <!-- </template> -->
          <!-- <template #avatar>
            <div class="wenZiJuZhong dateAndTime">
              <i class="fas fa-users" />
              <div>{{ item.shijian }}</div>
              <div style="color: #1ab394;">{{ item.tkrq }}</div>
            </div>
          </template> -->
        <!-- </a-list-item-meta> -->
      </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;
}

</style>