projectStatistic.vue 2.65 KB
<template>
  <div style="height: 70vh; overflow: auto;">
    <a-table :dataSource="tableData" :columns="columns" rowKey="knowledge2Id" :pagination="false" :loading="loading" bordered>
    </a-table>
  </div>
</template>

<script>
import { groupList } from '@/views/peAssign/config'
import { getType } from '@/views/utils/auth'
import { mergeRow } from '@/views/utils/common'

export default {
  name: "projectStatistic",
  data() {
    return {
      loading: false,
      columns: [
        { title: '一级学科', dataIndex: 'knowledge1Name', align: 'center', customRender: (text, row) => { return { children: `${text}`, attrs: { rowSpan: row.knowledge1NameRowSpan } } } },
        { title: '二级学科', dataIndex: 'knowledge2Name', align: 'left' },
        { title: '项目数', dataIndex: 'knowledgeCount', align: 'center' },
        { title: '总数', dataIndex: 'totalCount', align: 'center', customRender: (text, row) => { return { children: row.totalCount, attrs: { rowSpan: row.groupNameRowSpan } } } },
        { title: '分组', dataIndex: 'groupName', align: 'center', customRender: (text, row) => { return { children: `${text}`, attrs: { rowSpan: row.groupNameRowSpan } } } },
        { title: '分配专家', dataIndex: 'expertName', align: 'center', 
          customRender: (text, row) => {
            const array = []
            if (text != null && text !== '') {
              text.split('|').forEach(e => {
                array.push(<a-tag color="orange">{e}</a-tag>)
                array.push(<br/>)
              })
            }
            return { 
              children: array,//(<a-tag color="orange">{text}</a-tag>),
              attrs: { rowSpan: row.groupNameRowSpan } 
            }
          } 
        },
      ],
      tableData: [],//groupList(),
      reportYear: null
    };
  },
  created() {
    this.getYear()
  },
  mounted() {
    
  },
  methods: {
    getYear () {
      this.$api.batch.getCurrentYearBatch({ type: 1, projType: getType() }).then(({ data = {} }) => {
        if (data) {
          this.reportYear = data.year
          this.getProjectExpertGroupStatistic()
        }
      }).catch(() => { })
    },
    getProjectExpertGroupStatistic () {
      this.$api.statistical.getProjectExpertGroupStatistic({ reportYear: this.reportYear, auditType: 1, projType: getType() }).then(({ data = {} }) => {
        if (data) {
          this.tableData = data
        }
      }).catch(() => { })
    },
    exportData() {

    }
  },
  watch: {
    tableData: {
      handler (value) {
        mergeRow('knowledge1Name', this.tableData) // 合并knowledge1Name
        mergeRow('groupName', this.tableData) // 合并groupName
      }
    }
  }
};
</script>