<!--
  @description: 查询招标结果（进度）信息
  @Modifier: haofengxian
  @routerPath: /statisticalAnalysis/tenderScheduleList
  @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="tenderMethod" label="是否全流程" prop="tenderMethod">
        <el-select v-model="searchForm.tenderMethod" placeholder="请输入请选择" style="width: 220px">
          <el-option
            v-for="(item,index) in bidTypeList"
            :key="index"
            :label="item.typename"
            :value="item.typecode"/>
        </el-select>
      </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="buyersName" label="采购方" prop="buyersName">
        <el-input
          v-model.trim="searchForm.buyersName"
          style="width:220px"
          placeholder="请输入采购方"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item ref="areaIndustryCompany" label="区域产业公司" prop="areaIndustryCompany">
        <el-input
          v-model.trim="searchForm.areaIndustryCompany"
          placeholder="请输入区域产业公司"
          style="width:220px"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item label="公告发布时间">
        <el-date-picker
          v-model="searchForm.bulletinPublishTime"
          type="daterange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          style="width: 220px"
          @change="handleCreateTime"
        />
      </el-form-item>
      <!--项目分类-->
      <el-form-item
        ref="industryName"
        label="项目分类"
        prop="industryName"
      >
        <el-select v-model="searchForm.industryName" placeholder="请选择" style="width: 220px">
          <el-option
            v-for="item in projectClassificationList"
            :key="item.typecode"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </el-form-item>
      <!--代理机构-->
      <el-form-item ref="agentName" label="代理机构" prop="agentName">
        <el-input
          v-model.trim="searchForm.agentName"
          placeholder="请输入代理机构"
          style="width:220px"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <!--中标单位-->
      <el-form-item ref="winSupplierName" label="中标单位" prop="winSupplierName">
        <el-input
          v-model.trim="searchForm.winSupplierName"
          placeholder="请输入中标单位"
          style="width:220px"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <!--标段（包）状态-->
      <el-form-item ref="packStatus" label="标段（包）状态" prop="packStatus">
        <el-input
          v-model.trim="searchForm.packStatus"
          placeholder="请输入标段（包）状态"
          style="width:220px"
          @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 bidTypeList"
            :key="index"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </el-form-item>
      <!--项目经理-->
      <el-form-item ref="tenderManager" label="项目经理" prop="tenderManager">
        <el-input
          v-model.trim="searchForm.tenderManager"
          placeholder="请输入项目经理"
          style="width:220px"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
    </template>
    <template slot="menuLeft">
      <div class="mb10">
        <el-button type="primary" @click="exportCurrentPage">
          导出当前页面
        </el-button>
        <el-button type="primary" @click="exportAll">
          导出全部
        </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
          header-align="center"
          prop="areaIndustryCompany"
          label="区域产业公司"
          width="170"
        />
        <el-table-column

          header-align="center"
          prop="buyersName"
          label="采购方"
          width="170"
        />
        <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="industryName"
          label="项目分类"
          width="90"
        >
          <template slot-scope="scope">
            <span
              v-for="item in projectClassificationList"
              v-if="scope.row.industryName === item.typecode"
              :key="item.typecode"
            >{{ item.typename }}
            </span>
          </template>
        </el-table-column>
        <el-table-column

          header-align="center"
          prop="packName"
          label="标段（包）名称"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          prop="packNo"
          label="标段（包）编号"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          prop="tenderMethod"
          label="招标方式"
          width="80"
          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="budgetEstimate"
          align="right"
          label="概算"
          width="90"
        />
        <el-table-column
          header-align="center"
          prop="spareBudgetEstimate"
          align="right"
          label="定标金额（元）"
          width="120"
        />
        <el-table-column
          header-align="center"
          prop="spareBudgetEstimate"
          align="right"
          label="节省概算（元）"
          width="120"
        />
        <el-table-column
          header-align="center"
          prop="winSupplierName"
          label="中标单位"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          prop="reviewWay"
          label="评标办法"
          width="110"
        >
          <template slot-scope="scope">
            <span
              v-for="item in reviewWayList"
              v-if="scope.row.reviewWay === item.typecode"
              :key="item.typecode"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="qualificationMethod"
          label="资审方式"
          width="90"
        >
          <template slot-scope="scope">
            <span
              v-for="item in phaseTypeList"
              v-if="scope.row.qualificationMethod === item.typecode"
              :key="item.typecode"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="schemeSource"
          label="方案来源"
          align="center"
          width="90"
        >
          <template slot-scope="scope">
            <span
              v-for="item in schemeSourceList"
              v-if="scope.row.schemeSource === item.typecode"
              :key="item.typecode"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="进度标段（包）状态"
          prop="packStatus"
          width="130"
        />
        <el-table-column
          header-align="center"
          prop="tenderManager"
          label="项目经理"
          width="90"
        />
        <el-table-column
          header-align="center"
          prop="tenderDepart"
          label="业务部门"
          width="90"
        />
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { queryBidResultPage } 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: [], // 招标方式
      phaseTypeList: [], // 资格审查方式
      /* 字典信息-end */
      loading: true,
      // 搜索
      searchForm: {
        bulletinPublishTime: '', // 公告发布时间
        agentName: '', // 招标代理机构名称
        areaIndustryCompany: '', // 区域产业公司
        bulletinPublishEndTime: '', // 公告发布结束时间
        bulletinPublishStartTime: '', // 公告发布开始时间
        buyersName: '', // 采购方
        industryName: '', // 项目分类 01工程 02货物 03服务 04其他
        packName: '', // 标段（包）名称
        packStatus: '', // (进度)标段(包)状态 00:正在立项中
        tenderManager: '', // 项目经理
        tenderMethod: '', // 招标方式
        tenderName: '', // 项目名称
        tenderNo: '', // 项目编号
        winSupplierName: '' // 中标单位
      },
      tableData: []
    }
  },
  created() {
    this.initGroup() // 获取字典方法
    this.initProjectClassWebTypeGroup()// 项目分类
  },
  methods: {
    // 获取字典方法
    initGroup() {
      const data = [
        'bidType', // 招标方式
        'phaseType' // 资格审查方式
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 导出当前页面
    exportCurrentPage() {

    },
    // 导出全部
    exportAll() {

    },
    // 导出招标结果Excel
    exportExcel(feeDocIds) {
      const params = {
        feeDocIds
      }
      exportInvoiceList(params).then(res => {
        download(res, '开票记录.xls')
      }).catch(() => {
      })
    },
    // 获取数据
    loadData(params, callback) {
      queryBidResultPage(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    },
    // 处理搜索时间格式
    handleCreateTime(val) {
      if (val) {
        this.searchForm.bulletinPublishStartTime = this.$Moment(val[0]).format(this.momentSaveFormat)// 创建开始时间
        this.searchForm.bulletinPublishEndTime = this.$Moment(val[1]).format(this.momentSaveFormat)// 创建结束时间
      }
    }
  }
}
</script>
<style lang="less" scoped>

</style>
