<!--
  @description: 项目信息库-列表
  @Modifier: haofengxian
  @routerPath: /informationbase/projectInfoBaseList
  @date: 2020-5-8-11:20
-->
<template>
  <table-crud
    :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="招标项目编号"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item ref="tenderName" label="项目名称" prop="tenderName">
        <el-input
          v-model.trim="searchForm.tenderName"
          placeholder="项目名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <el-form-item ref="packName" label="标段（包）名称" prop="packName">
        <el-input
          v-model.trim="searchForm.packName"
          placeholder="标段（包）名称"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>
      <!--      <el-form-item ref="packStatus" label="标段（包）状态" prop="packStatus">
        <el-input
          v-model.trim="searchForm.packStatus"
          placeholder="标段（包）状态"
          @keyup.enter.native="search.onSearch"
        />
      </el-form-item>-->
      <el-form-item ref="managerName" label="项目经理" prop="managerName">
        <el-input
          v-model.trim="searchForm.managerName"
          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: 200px">
          <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="industryName" label="项目分类" prop="industryName">
        <el-select v-model="searchForm.industryName" placeholder="请选择" style="width: 200px">
          <el-option
            v-for="(item,index) in financecloudGuaranteeTenderTypeList"
            :key="index"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </el-form-item>
    </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="160"
        />
        <el-table-column

          header-align="center"
          prop="tenderName"
          label="招标项目名称"
          min-width="230"
        />
        <el-table-column
          header-align="center"
          prop="managerName"
          label="项目经理"
          min-width="100"
          align="center"
        />
        <el-table-column
          label="项目分类"
          prop="industryName"
          align="center"
          min-width="100"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in financecloudGuaranteeTenderTypeList"
              v-if="scope.row.industryName===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="招标方式"
          prop="tenderMethod"
          align="center"
          width="100"
        >
          <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"

          label="标段（包）名称"
          prop="packName"
          min-width="160"
        />
        <el-table-column
          header-align="center"
          label="标段（包）状态"
          prop="packStatus"
          min-width="110"
        />
        <el-table-column
          header-align="center"
          label="操作"
          width="80"
          align="center"
        >
          <template slot-scope="scope">
            <el-link
              type="primary"
              @click.stop="viewProjectInfo(scope.row)"
            >
              [查看]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </table-crud>
</template>

<script>
/* 接口*/
import { queryInformationBaseList } from '@api/bidding/biddingProject'
export default {
  name: 'RepresentativeTendereeList',
  data() {
    return {
      /* 字典信息-start */
      bidTypeList: [], // 招标方式
      financecloudGuaranteeTenderTypeList: [], // 项目分类
      /* 字典信息-end */
      loading: true,
      tableData: [], // 项目信息列表
      // 搜索
      searchForm: {
        buyersTenderNo: '', // 招标人项目编号
        industryName: '', // 项目分类 01工程 02货物 03服务 04其他
        isOperation: '', // 业务操作 保存:00 提交:01
        managerName: '', // 项目经理
        orderBy: '', // 排序
        packName: '', // 标段名称
        packStatus: '', // 标段状态
        tenderMethod: '', // 招标方式 : 公开招标 00 邀请招标 01 竞争性谈判 02 询价 03 单一来源采购 04 其他 05
        tenderName: '', // 项目名称
        tenderNo: '' // 项目编号
      }
    }
  },
  created() {
    this.initGroup() // 获取字典方法
  },
  methods: {
    // 获取字典方法
    initGroup() {
      const data = [
        'bidType', // 招标方式
        'financecloudGuaranteeTenderType' // 项目分类
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 获取数据
    loadData(params, callback) {
      queryInformationBaseList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
      })
    },
    // 查看
    viewProjectInfo(row) {
      this.$router.push({
        path: '/informationbase/projectInfoBaseDetail',
        name: 'projectInfoBaseDetail',
        params: {
          id: row.id
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
