<!--
  @description:开评标计划统计
  @Modifier: haofengxian
  @routerPath:/statisticalAnalysis/bidEvaluationPlanList
  @date: 2020-7-14-16:30
-->
<template>
  <table-crud
    :menu="true"
    :search-form="searchForm"
    search-label-width="110px"
    @on-load="loadData"
  >
    <template v-slot:header>
      查询开评标统计信息
    </template>
    <template v-slot:search="search">
      <el-form-item ref="tenderNo" label="项目编号" prop="tenderNo">
        <el-input
          v-model.trim="searchForm.tenderNo"
          placeholder="项目编号"
          style="width:220px"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item ref="packName" label="标段名称" prop="packName">
        <el-input
          v-model.trim="searchForm.packName"
          style="width:220px"
          placeholder="标段名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item ref="tenderManager" label="项目经理" prop="tenderManager">
        <el-input
          v-model.trim="searchForm.tenderManager"
          style="width:220px"
          placeholder="项目经理"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item ref="tenderName" label="项目名称" prop="tenderName">
        <el-input
          v-model.trim="searchForm.tenderName"
          style="width:220px"
          placeholder="项目名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <!--开标方式-->
      <el-form-item
        ref="tenderMethod"
        label="开标方式"
        prop="tenderMethod"
      >
        <el-select v-model="searchForm.tenderMethod" placeholder="请选择" style="width: 220px">
          <el-option
            v-for="(item,index) in bidOpeningMethodList"
            :key="index"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </el-form-item>
      <!--开标阶段-->
      <el-form-item
        ref="openStageType"
        label="开标阶段"
        prop="openStageType"
      >
        <el-select v-model="searchForm.openStageType" placeholder="请选择" style="width: 220px">
          <el-option
            v-for="(item,index) in openStageTypeList"
            :key="index"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="开标日期">
        <el-date-picker
          v-model="searchForm.openBidStartTime"
          type="daterange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          style="width: 220px"
          @change="handleOpenBidStartTime"
        />
      </el-form-item>
    </template>

    <template slot="menuLeft">
      <div class="mb10">
        <el-button type="primary" @click="derivedRecord">
          导出记录
        </el-button>
      </div>
    </template>
    <template v-slot:GXTable>
      <el-table
        ref="smallTable"
        v-loading="loading"
        :data="tableData"
      >
        <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
        />
        <el-table-column
          prop="tenderNo"
          align="center"
          label="招标项目编号"
          width="170"
        />
        <el-table-column
          header-align="center"
          prop="tenderName"
          label="招标项目名称"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          prop="tenderMethod"
          label="招标方式"
          width="100"
          align="center"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in bidTypeList"
              v-if="scope.row.tenderMethod===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="tenderManager"
          label="项目经理"
          width="90"
        />
        <el-table-column
          header-align="center"
          label="标段（包）名称"
          prop="packName"
          align="left"
          min-width="200"
        />
        <el-table-column
          label="标段（包）状态"
          prop="packStatus"
          width="110"
        />
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { queryEvalListPage } from '@api/statisticalAnalysis'
import { exportInvoiceList } from '@api/fee/docfee'
/* 公用方法*/
import { download } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { statisticalAnalysisGroupMixin } from '../mixins/statisticalAnalysisGroupMixin'
export default {
  name: 'TenderProjectList',
  mixins: [statisticalAnalysisGroupMixin],
  data() {
    return {
      /* 字典信息-start */
      bidTypeList: [], // 招标方式
      /* 字典信息-end */
      loading: true,
      // 搜索
      searchForm: {
        openBidStartTime: '', // 开标时间
        bidOpeningMethod: '', // 开标方式，00网上，01线下
        openBidStartTimeEnd: '', // 开标时间-结束
        openBidStartTimeStart: '', // 开标时间-开始
        openStageType: '', // 00一次开标阶段(商务技术经济)，01非价格开标阶段(商务技术)，02价格开标阶段(经济)，03:资审开标阶段(商务技术)
        packName: '', // 标段（包）名称
        tenderManager: '', // 项目经理
        tenderName: '', // 项目名称
        tenderNo: '' // 项目编号
      },
      tableData: []
    }
  },
  created() {
    this.initGroup() // 获取字典方法
  },
  methods: {
    // 获取字典方法
    initGroup() {
      const data = [
        'bidType' // 招标方式
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 导出记录
    derivedRecord() {

    },
    // 导出记录Excel
    exportExcel(feeDocIds) {
      const params = {
        feeDocIds
      }
      exportInvoiceList(params).then(res => {
        download(res, '开评标统计记录.xls')
      }).catch(() => {
      })
    },
    // 获取数据
    loadData(params, callback) {
      queryEvalListPage(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    },
    // 处理搜索时间格式
    handleOpenBidStartTime(val) {
      if (val) {
        this.searchForm.openBidStartTimeStart = this.$Moment(val[0]).format(this.momentDate)// 开始时间
        this.searchForm.openBidStartTimeEnd = this.$Moment(val[1]).format(this.momentDate)// 结束时间
      }
    }
  }
}
</script>
<style lang="less" scoped>

</style>
