<template>
  <div class="pa-3 white fill-height d-flex flex-column">
    <r-d-search @searchServiceApply="searchServiceApply" />
    <r-d-date :lists="lists" :pagination="pagination" @searchServiceApply="searchServiceApply" />
  </div>
</template>

<script>
// @ is an alias to /src
import RDSearch from 'components/RD/RDSearch.vue';
import RDDate from 'components/RD/RDDate.vue';
import { searchServiceApply } from 'config/api';

export default {
  name: 'RDTeam',
  components: {
    RDSearch,
    RDDate,
  },
  data() {
    return {
      str: '需求填报界面',
      pagination: { current: 1, pageSize: 10 },
      lists: {},
    };
  },
  created() {
    this.searchServiceApply();
  },

  methods: {
    /**
     * 根据团队id查看研发团队相关信息
     * @param { String } competeTimeId 第几届信息的id
     */
    async searchServiceApply(paramData) {
      try {
        const params = {
          param: {
            companyName: paramData && paramData.companyName !== '' ? paramData.companyName : '',
            contactName: paramData && paramData.contactName !== '' ? paramData.contactName : '',
            contactPhone: paramData && paramData.contactPhone !== '' ? paramData.contactPhone : '',
            type: paramData && paramData.type !== '' ? paramData.type : '',
            pageNum: paramData && paramData.current ? paramData.current : 1,
            pageSize: paramData && paramData.pageSize ? paramData.pageSize : 10,
            serviceType: 1,
          },
        };
        const res = await searchServiceApply(params);
        const { code, msg, data } = res.data;
        if (code === 200) {
          this.lists = data;
          const paper = { ...this.pagination };
          paper.current = data.pageNum;
          paper.total = +data.total;
          paper.pageSize = data.pageSize;
          this.pagination = paper;
        } else {
          throw msg || '获取失败';
        }
      } catch (error) {
        this.$message.error(error);
      }
    },
  },
};
</script>
