<!--
  @description:查询归档信息统计
  @Modifier: haofengxian
  @routerPath:/statisticalAnalysis/archivedInfoList
  @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="winSupplierName" label="中标人" prop="winSupplierName">
        <el-input
          v-model.trim="searchForm.winSupplierName"
          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="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="projectAgentName" label="招标机构" prop="projectAgentName">
        <el-input
          v-model.trim="searchForm.projectAgentName"
          style="width:220px"
          placeholder="招标机构"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <!--部门名称-->
      <el-form-item ref="tenderDepart" label="部门名称" prop="tenderDepart">
        <el-input
          v-model.trim="searchForm.tenderDepart"
          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 label="中标日期">
        <el-date-picker
          v-model="searchForm.winningTime"
          type="daterange"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          style="width: 220px"
          @change="handleCreateTime"
        />
      </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
          fixed
          type="index"
          label="序号"
          width="60px"
          align="center"
        />
        <el-table-column
          fixed
          prop="tenderNo"
          align="center"
          label="项目编号"
          width="170"
        />
        <el-table-column
          fixed
          header-align="center"
          prop="tenderName"
          label="项目名称"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          prop="tenderDepart"
          label="部门名称"
          min-width="100"
        />
        <el-table-column
          header-align="center"
          prop="managerName"
          label="项目经理"
          width="90"
        />
        <el-table-column
          header-align="center"
          prop="manageTel"
          label="项目经理电话"
          min-width="120"
        />
        <el-table-column
          header-align="center"
          prop="buyersName"
          label="招标人"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          prop="buyersLinkerTel"
          label="招标人联系方式"
          min-width="160"
        />
        <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="mediaPartners"
          label="招标公告发布媒体"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          prop="bulletinPublishTime"
          label="公告发布时间"
          width="130"
        >
          <template slot-scope="scope">
            {{ scope.row.bulletinPublishTime && $Moment(scope.row.bulletinPublishTime).format(momentDateTime) }}
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="openBidStartTime"
          label="开标时间"
          width="130"
        >
          <template slot-scope="scope">
            {{ scope.row.openBidStartTime && $Moment(scope.row.openBidStartTime).format(momentDateTime) }}
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="contractPrice"
          label="委托金额（万元）"
          width="120"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="winningResultPrice"
          label="中标金额（万元）"
          width="120"
          align="right"
        />
        <el-table-column
          header-align="center"
          prop="winSupplierName"
          label="中标单位"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          label="中标时间"
          width="130"
        >
          <template slot-scope="scope">
            {{ scope.row.winningTime && $Moment(scope.row.winningTime).format(momentDateTime) }}
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="winDepartLinker"
          label="中标单位联系人"
          width="130"
        />
        <el-table-column
          header-align="center"
          prop="winDepartLinkerTel"
          label="中标单位联系电话"
          width="130"
        />
        <el-table-column
          header-align="center"
          label="操作"
          width="90"
          fixed="right"
          align="center"
        >
          <template slot-scope="scope">
            <el-link
              type="primary"
              @click.stop="examine(scope.row)"
            >
              [查看]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>
<script>
/* 接口*/
import { queryArchivePage } from '@api/statisticalAnalysis'
import { exportInvoiceList } from '@api/fee/docfee'
/* 公用方法*/
import { download } from '@/assets/js/utils'// 常用方法

export default {
  name: 'TenderProjectList',
  data() {
    return {
      /* 字典信息-start */
      bidTypeList: [], // 招标方式
      /* 字典信息-end */
      loading: true,
      // 搜索
      searchForm: {
        winningTime: '', // 中标日期
        buyersName: '', // 招标人名称
        projectAgentName: '', // 招标机构
        tenderDepart: '', // 业务部门
        tenderManager: '', // 项目经理
        tenderMethod: '', // 招标方式
        tenderName: '', // 招标项目名称
        tenderNo: '', // 招标项目编号
        winSupplierName: '', // 中标单位
        winningEndTime: '', // 中标结束时间
        winningStartTime: '' // 中标开始时间
      },
      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) {
      queryArchivePage(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    },
    // 查看
    examine() {

    },
    // 处理搜索时间格式
    handleCreateTime(val) {
      if (val) {
        this.searchForm.winningStartTime = this.$Moment(val[0]).format(this.momentDate)// 开始时间
        this.searchForm.winningEndTime = this.$Moment(val[1]).format(this.momentDate)// 结束时间
      }
    }
  }
}
</script>
<style lang="less" scoped>

</style>
