assignDetail.vue 11.1 KB
<template>
  <div class="app-content" style="height:70vh;overflow:auto;">
    <a-form :form="form" :model="searchForm" layout="inline" class="search_form">
      <a-form-item>
        <a-input placeholder="项目名称" v-model="searchForm.projName" :maxLength="100" style="width: 160px" />
      </a-form-item>
      <a-form-item>
        <a-select v-if="groupList" default-value="" placeholder="项目分组" v-model="searchForm.groupId" style="width: 160px" @change="groupChange">
          <a-select-option v-for="item in groupList" :key="item.groupId" :value="item.groupId">{{ item.groupName }}</a-select-option>
        </a-select>
        <!-- <a-input placeholder="项目分组" v-model="searchForm.groupId" :maxLength="100" style="width: 160px" /> -->
      </a-form-item>
      <!-- <a-form-item>
        <base-select v-model="searchForm.assignYear" :title="'年度'" :type="8" :isAll="true" :width="160" />
      </a-form-item> -->
      <a-form-item>
        <a-input v-model="searchForm.appPersonName" placeholder="项目负责人" :maxLength="20" style="width: 130px" />
      </a-form-item>
      <a-form-item>
        <a-input v-model="searchForm.appUnitName" placeholder="申报单位" :maxLength="100" style="width: 130px" />
      </a-form-item>
      <a-form-item>
        <a-input v-model="searchForm.personName" placeholder="评审专家" :maxLength="100" style="width: 130px" />
      </a-form-item>
      <a-form-item>
        <a-select v-model="searchForm.auditState" style="width: 130px">
          <a-select-option value="">--评审状态--</a-select-option>
          <a-select-option value="0">未评审</a-select-option>
          <a-select-option value="1">未提交</a-select-option>
          <a-select-option value="2">已提交</a-select-option>
        </a-select>
      </a-form-item>
      <a-form-item>
        <a-button type="primary" icon="search" @click="search">搜索</a-button>
        <!-- <a-button icon="reload" style="margin-left: 10px" @click="reset" class="bt-normal">重置</a-button> -->
        <a-button type="primary" style="margin-left: 10px" @click="exportData" icon="download">导出</a-button>
      </a-form-item>
    </a-form>
    <a-divider style="height: 1px; background-color: #e8e8e8;" />
    <a-table :dataSource="tableData" :columns="columns" rowKey="id" :pagination="false" :loading="loading">
      <template slot="projName" slot-scope="record">
        <a-tooltip placement="topLeft">
          <template slot="title">
            <span>{{ record.projName }}</span>
          </template>
          <a @click="recordClick(record,'view')">{{record.projName}}</a>
        </a-tooltip>
      </template>
      <template slot="spec" slot-scope="record">
        <span v-for="data in record.specList" :key="data.id" :color="'green'">{{data.specName+' '}}</span>
      </template>
      <template slot="expertEvaluation" slot-scope="record">
        <a-tag :color="evaluationColor(record)">{{evaluationText(record)}}</a-tag>
      </template>
      <template slot="projClassInfo" slot-scope="record">
        {{ record.projClass == 1 ? "一般项目" : "重点项目" }}
      </template>
      <template slot="expertInfo" slot-scope="record">
        <a-tag :color="record.expertType == 1 ? technology : finance">{{ record.expertType == 1 ? "技术专家" : "财务专家" }}</a-tag>
      </template>
      <template slot="option" slot-scope="record">
        <a-popconfirm title="确定要删除吗?" ok-text="确定" cancel-text="取消" @confirm="recordClick(record,'del')">
          <a-button type="link" size="small">删除</a-button>
        </a-popconfirm>
      </template>
    </a-table>
    <a-pagination v-if="pagination.total > 0" :total="pagination.total" show-size-changer show-quick-jumper v-model="pagination.pageIndex" :page-size="pagination.pageSize" :page-size-options="pagination.pageSizeOptions" @showSizeChange="showSizeChange" @change="change" :showTotal="() => `共 ${pagination.total} 条`" />
    <a-modal v-model="visibleView" v-if="visibleView" title="项目详情" width="94%" :footer="null" :dialog-style="{ top: '8%' }" destroyOnClose :maskClosable="false">
      <project-view v-model="projId" @close="() => this.visibleView = false" />
    </a-modal>
  </div>
</template>

<script>
import moment from 'moment'
import { getType } from '@/views/utils/auth'
import { isEmptyParams, filterExportExcelData, tableColumnsName, } from '@/views/utils/common'
import baseSelect from '@/views/components/common/baseSelect'
import projectView from '@/views/report/project/components/projectView'

export default {
  name: 'assignDetail',
  props: {
    groupList: {
      type: Array,
      default: () => {
        return [{ groupId: "", groupName: "--请选择分组--" }]
      }
    },
  },
  components: {
    baseSelect, projectView
  },
  data () {
    return {
      form: this.$form.createForm(this, { name: 'assign_search' }),
      searchForm: { projName: null, groupId: "", assignYear: null, appUnitName: null, appPersonName: null, personName: null, auditState: "", projType: getType() },
      tableData: [],
      columns: [
        { title: "项目名称", scopedSlots: { customRender: 'projName' }, ellipsis: true, width: 300, },
        { title: "申报学科", dataIndex: 'knowledgeName', align: 'center', ellipsis: true, },
        { title: "项目负责人", dataIndex: 'appPersonName', align: 'center' },
        { title: "项目分组", dataIndex: 'groupName', align: 'center' },
        { title: "项目类别", scopedSlots: { customRender: 'projClassInfo' }, align: 'center' },
        { title: '申报单位', dataIndex: 'appUnitName', align: 'center', ellipsis: true },
        // { title: '项目编号', dataIndex: 'projNo', align: 'center' },
        // { title: '性别', dataIndex: 'sex', align: 'center' },
        // { title: '证件号', dataIndex: 'certId', align: 'center' },
        { title: '专家姓名', dataIndex: 'personName', align: 'center' },
        { title: '评审专业', dataIndex: 'specNames', align: 'center', ellipsis: true },
        { title: "专家类型", scopedSlots: { customRender: 'expertInfo' }, align: 'center' },
        { title: '专家单位', dataIndex: 'unitName', align: 'center', ellipsis: true },
        { title: '手机号', dataIndex: 'mobile', align: 'center' },
        // { title: '邮箱', dataIndex: 'email', align: 'center' },
        // { title: '职称', dataIndex: 'titleName', align: 'center' },
        // { title: '评审专业', scopedSlots: { customRender: 'spec' }, align: 'center' },
        { title: '评分', dataIndex: 'totalScore', align: 'center', width: 60 },
        { title: '评审状态', scopedSlots: { customRender: 'expertEvaluation', colName: 'gradeScore' }, align: 'center' },
        // { title: '操作', scopedSlots: { customRender: 'option' }, align: 'center', fixed: 'right', width: 120, },
      ],
      pagination: { pageIndex: 1, pageSize: this.$defaultPageSize, total: 0, pageSizeOptions: this.$defaultPageSizeOptions },
      loading: false,
      projId: null,
      visibleView: false,
      technology: "#2db7f5",
      finance: "#87d068",
    }
  },
  created () {
    this.getYear()
  },
  methods: {
    moment,
    getYear () {
      this.$api.batch.getCurrentYearBatch({ type: 1, projType: getType(), timeType: 1 }).then(({ data = {} }) => {
        if (data) {
          this.searchForm.assignYear = data.year
          this.getListByPage()
        }
      }).catch(() => { })
    },
    getListByPage () {
      this.loading = true
      let pars = isEmptyParams(this.searchForm)
      let par = { ...pars, pageIndex: this.pagination.pageIndex, pageSize: this.pagination.pageSize }
      this.$api.projectAssign.getListByPage(par).then(({ data = {} }) => {
        if (data) {
          const { dataList = [], total = 0 } = data
          this.tableData = dataList.map(item => {
            return {
              ...item,
              expertTypeName: item.expertType === 1 ? "技术专家" : "财务专家",
              projClassName: item.projClass === 1 ? "一般项目" : "重点项目",
              specNames: item.specList ? item.specList.map(e => e.specName).join(',') : ''
            }
          })
          this.pagination.total = total
          this.loading = false
        }
      }).catch(() => { this.loading = false })
    },
    change () {
      this.getListByPage()
    },
    showSizeChange (current, pageSize) {
      this.pagination.pageSize = pageSize
      this.getListByPage()
    },
    search () {
      this.pagination.pageIndex = 1
      this.getListByPage()
    },
    reset () {
      this.searchForm.personName = ''
      this.searchForm.certId = ''
      this.searchForm.sex = ''
      this.pagination.pageIndex = 1
      this.getListByPage()
    },
    groupChange (value) {
      this.searchForm.groupId = value
    },
    recordClick (record, type) {
      if (type === 'view') {
        this.projId = record.projId
        this.visibleView = true
      } else if (type === 'del') {
        this.loading = true
        this.$api.projectAssign.deleteAssignExpert({ id: record.id }).then(({ data = {} }) => {
          if (data) {
            this.$message.success('删除成功')
            this.getListByPage()
          }
          this.loading = false
        }).catch(() => {
          this.loading = false
        })
      }
    },
    evaluationColor (record) {
      let color = ''
      switch (record.auditState) {
        case 0:
          color = '#f50';
          break;
        case 1:
          color = '#2db7f5';
          break;
        case 2:
          color = '#87d068';
          break;
      }
      return color
    },
    evaluationText (record) {
      let text = ''
      switch (record.auditState) {
        case 0:
          text = '未评审';
          break;
        case 1:
          text = '未提交';
          break;
        case 2:
          text = '已提交';
          break;
      }
      return text
    },
    exportData () {
      this.loading = true
      let column = [
        { title: "项目名称", dataIndex: 'projName' },
        { title: "申报学科", dataIndex: 'knowledgeName' },
        { title: "项目负责人", dataIndex: 'appPersonName' },
        { title: "项目分组", dataIndex: 'groupName' },
        { title: "项目类别", dataIndex: 'projClassName' },
        { title: '申报单位', dataIndex: 'appUnitName' },
        { title: '专家姓名', dataIndex: 'personName' },
        { title: '评审专业', dataIndex: 'specNames' },
        { title: "专家类型", dataIndex: 'expertTypeName' },
        { title: '专家单位', dataIndex: 'unitName' },
        { title: '手机号', dataIndex: 'mobile' },
        { title: '评分', dataIndex: 'totalScore' },
        { title: '评审状态', dataIndex: 'stateName' },
      ]
      let pars = isEmptyParams(this.searchForm)
      let par = { ...pars, pageIndex: -1, pageSize: -1 }
      this.$api.projectAssign.getListByPage(par).then(({ data = {} }) => {
        if (data) {
          const { dataList = [], total = 0 } = data
          this.$ToDoExcel(`项目分配列表`, tableColumnsName(column), filterExportExcelData(column, dataList))
          dataList = []
        }
        this.loading = false
      }).catch(() => { this.loading = false })
    },
  }
}
</script>