<template>
  <div class="indexBackClass" id="stuwdkcDom">
    <div style="margin-top: 20px;">
        <span style="margin-left: 30px;font-size: 24px;font-weight: 600;">提醒信息</span>
    </div>
    <div style="min-height:70px;">
      <a-row>
        <a-col :span="24" style="padding: 0 10px;margin-bottom: 10px;"  v-for="(item,index2) in dataSource" :key="index2">
          <a-row style="margin-top: 15px;">
            <a-col :span="18" style="text-align:left;padding-left:15px;">
              <div>{{index2+1}}、{{item.content}}</div>
            </a-col>
            <a-col :span="6" style="text-align:right">
              <span>提醒时间：{{item.createTime}}</span>
              <a-button type="primary" @click="openKecheng(item)" style="margin-left:10px;">查看</a-button>
            </a-col>
          </a-row>
        </a-col>
        <a-col :span="24" v-show="dataSource.length == 0" style="text-align: center;">
          <span style="line-height:60px;">暂无提醒</span>
        </a-col>
      </a-row>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { defHttp } from '/@/utils/http/axios';
import { ref, onMounted  } from 'vue';
import { getSysConfig } from '/@/views/site/utils/index';
//用户相关
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
const dataSource = ref([]);
  //进入就加载
onMounted(() => {
    loaddata()
  setInterval(() => {
    loaddata()
  }, 60*1000);
});
function loaddata(){
  defHttp.get({ url: '/zyDbtx/zyDbtx/list',params:{pageSize:10,pageNo:1,createBy:userStore.getUserInfo.username} }).then((res) => {
  dataSource.value = res.records;
  });
}

function openKecheng(record){
  console.log(`🚀 ~ openKecheng ~ record:`, record)
  
  defHttp.post({ url: '/zyDbtx/zyDbtx/deleteById',params:{id:record.id} }).then((res) => {
    loaddata()
  });
  var url = "/zy/zuoyeMain";
  if(record.type=='5'){//当前作业
    url = "/zy/dqkcDqzy";
  }else if(record.type=='6'){//测验消息
    url = "/zy/ceshiWenjuan";
  }else if(record.type=='7'){//问卷消息
    url = "/zy/dcwjWenjuan";
  }
  url = url +"?rwbh="+record.rwbh+"&xqxn="+getSysConfig().flag1+"&teano="+record.fbr;
  window.open(url,'_blank')
}

</script>

<style lang="less" scoped>
.indexBackClass{
  background: #fff;
  margin: 20px 0;
  padding-bottom: 20px;
}

.jtkcTitleClass{
  background-image:  linear-gradient(to right ,#1c84c6, #67b4e5);
  color: white;
  line-height: 30px;
  padding: 3px 0 0 10px;
  font-weight: 600;
  height: 30px;
}
</style>
