<template>
  <div class="requirement-list">
    <MiniList :list="requirementList" :pageSize="7" />
  </div>
</template>

<script>
import { listRequirements } from '@/api/oa/requirement';
import MiniList from '@/components/HomeModules/components/MiniList.vue';

export default {
  name: 'RequirementList',
  components: { MiniList },
  data() {
    return {
      requirementList: []
    }
  },
  mounted() {
    this.fetchRequirements();
  },
  methods: {
    async fetchRequirements() {
      try {
        const res = await listRequirements({ pageNum: 1, pageSize: 50 });
        this.requirementList = (res.rows || res.data || []).map(item => ({
          title: item.title || item.requirementTitle || '无标题',
          date: item.createTime || item.updateTime || '',
          id: item.id || item.requirementId || item.key || Math.random()
        }));
      } catch (e) {
        this.requirementList = [];
      }
    }
  }
}
</script>

<style scoped>
.requirement-list {
  padding: 0;
}
</style>
