<template>
  <div id="index">
    <el-row>
      <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
        <cHead :is_menu="false">
          <template v-slot:info>
            <div class="w_1200">
              <el-col :span="24" class="one">
                <el-tabs v-model="activeName" @tab-click="handleClick">
                  <el-tab-pane label="全部报名" name="0"></el-tab-pane>
                  <el-tab-pane label="会议报名" name="1"></el-tab-pane>
                  <el-tab-pane label="培训报名" name="2"></el-tab-pane>
                  <el-tab-pane label="通知公告" name="3"></el-tab-pane>
                </el-tabs>
              </el-col>
              <el-col :span="24" class="two">
                <el-col :span="24" class="list" v-for="(item, index) in list" :key="index" @click="toView(item)">
                  <el-col :span="17" class="left textOver">
                    <span class="value" :class="[item.status == '0' ? 'status0' : 'status1']">{{ item.status == '0' ? '会议' : '培训' }}</span>
                    {{ item.title || '暂无标题' }}
                  </el-col>
                  <el-col :span="7" class="right">
                    <span class="time">{{ moment(item.time).format('MM-DD HH:mm') }}</span>
                    &nbsp;
                    <span class="time">{{ item.status == '0' ? '报名已截止' : '报名已截止' }}</span>
                  </el-col>
                </el-col>
              </el-col>
              <el-col :span="24" class="thr">
                <a-pagination
                  v-model:page-size="limit"
                  show-size-changer
                  :page-size-options="pageSizeOptions"
                  :total="total"
                  @showSizeChange="onShowSizeChange"
                />
              </el-col>
            </div>
          </template>
        </cHead>
      </el-col>
    </el-row>
  </div>
</template>

<script setup lang="ts">
// 基础
import type { TabsPaneContext } from 'element-plus';
import type { Ref } from 'vue';
import { onMounted, getCurrentInstance, ref } from 'vue';
import { useRouter } from 'vue-router';
import moment from 'moment';
// 接口
// import { ToolsStore } from '@/stores/tool';
// import type { IQueryResult } from '@/util/types.util';
// const toolsAxios = ToolsStore();
const { proxy } = getCurrentInstance() as any;

// 路由
const router = useRouter();
// 加载中
const loading: Ref<any> = ref(false);
let list: Ref<any> = ref([
  {
    title: '关于浙江大学衢州研究院1件技术秘密转让的公示',
    time: '2023-07-31',
    status: '0'
  },
  {
    title: '浙江省科学技术厅 关于第七届中国创新挑战赛（浙江）暨 2022年浙江省技术需求“揭榜挂帅”大赛技术需求公告',
    time: '2023-07-31',
    status: '1'
  },
  {
    title: '关于浙江大学衢州研究院1件技术秘密转让的公示',
    time: '2023-07-31',
    status: '0'
  },
  {
    title: '关于浙江大学衢州研究院1件技术秘密转让的公示',
    time: '2023-07-31',
    status: '0'
  },
  {
    title: '关于浙江大学衢州研究院1件技术秘密转让的公示',
    time: '2023-07-31',
    status: '0'
  },
  {
    title: '关于浙江大学衢州研究院1件技术秘密转让的公示',
    time: '2023-07-31',
    status: '1'
  },
  {
    title: '关于浙江大学衢州研究院1件技术秘密转让的公示',
    time: '2023-07-31',
    status: '1'
  },
  {
    title: '关于浙江大学衢州研究院1件技术秘密转让的公示',
    time: '2023-07-31',
    status: '1'
  },
  {
    title: '关于浙江大学衢州研究院1件技术秘密转让的公示',
    time: '2023-07-31',
    status: '0'
  }
]);
let total: Ref<number> = ref(12);
let skip = 0;
let limit: number = proxy.$limit;
const pageSizeOptions = ref<string[]>(['12', '24', '60', '120']);
const activeName = ref('0');
// 请求
onMounted(async () => {
  loading.value = true;
  await searchOther();
  await search({ skip, limit });
  loading.value = false;
});
const search = async (e: { skip: number; limit: number }) => {
  const info = { skip: e.skip, limit: e.limit };
  //   const res: IQueryResult = await userCheckAxios.query(info);
  //   if (res.errcode == '0') {
  //     list.value = res.data;
  //     total.value = res.total;
  //   }
};
// 查询其他信息
const searchOther = async () => {
  //   let res: IQueryResult;
  //   // 性别
  //   res = await dictAxios.query({ type: 'common_gender' });
  //   if (res.errcode == '0') genderList.value = res.data;
};
// 活动大厅报告通知查看详情
const toView = (item) => {
  router.push({ path: '/activity/new', query: { id: item.id || item._id } });
};
const onShowSizeChange = (current: number, pageSize: number) => {
  console.log(current, pageSize);
  limit = pageSize;
};
const handleClick = (tab: TabsPaneContext, event: Event) => {
  console.log(tab, event);
}
</script>
<style scoped lang="scss">
.main {
  .two {
    .list:hover {
      box-shadow: 0 0 16px rgba(35, 116, 255, 0.6);
    }

    .list {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 30px;
      padding: 20px;
      border-bottom: 1px solid #dcdfe6;

      .left {
        font-size: 16px;
        color: #383b40;
        letter-spacing: 0;
        line-height: 24px;
        cursor: pointer;

        .value {
          padding: 2px 10px;
          border-radius: 12px;
          margin-right: 5px;
          font-size: 12px;
          line-height: 20px;
          text-align: center;
        }

        .status0 {
          background: rgba(35, 116, 255, 0.05);
          color: #2374ff;
        }

        .status1 {
          background: rgba(18, 172, 117, 0.05);
          color: #12ac75;
        }
      }

      .left:hover {
        color: #2374ff;
      }

      .right {
        text-align: center;

        .time {
          color: #aaaaaa;
        }

        .date {
          color: #525a68;
        }
      }
    }
  }

  .thr {
    display: flex;
    flex-direction: row-reverse;
    padding: 10px 0;
  }
}
</style>
