<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;">
              <!-- {{item.content}} -->
              <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;">
          <!-- <a-empty/> -->
          <span>暂无通知</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 = "/stuzy/studentMain";
  if(record.type=='0'||record.type=='1'){//当前作业+评分
    url = "/stuzy/studentDqzy";
  }else if(record.type=='2'){//测验消息
    url = "/stuzy/stuCeshiWenjuan";
  }else if(record.type=='3'){//问卷消息
    url = "/stuzy/stuDcwjWenjuan";
  }else if(record.type=='4'){//讨论区
    url = "/stuzy/stuTlq";
  }else if(record.type=='9'){//通知公告
    url = "/stuzy/StudentGonggaoList";
  }
  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>
