<!--
  @description: 认领项目信息列表
  @Modifier: haoFx
  @routerPath: /bidding/bidProjectClaimList
  @date: 2019/10/25-17:52
-->
<template>
  <div>
    <!--标题-->
    <div class="title title_border p0-16">
      <i class="el-icon-s-home" />认领招标项目信息列表
    </div>
    <section class="p0-16">
      <!--查询条件-->
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询条件</span>
        <span class="fr pointer" @click="handleToggleSearch">
          <el-link
            :underline="false"
            :class="toggleSearchStatus?'arrow-is-active':''"
            type="primary"
            class="toggleSearchStatus icon el-icon-arrow-down"
          />
          {{ toggleSearchStatus?'收起高级查询' :'展开高级查询' }}
        </span>
      </div>
      <div :class="{'SearchContent_show':toggleSearchStatus}" class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
            label-width="100px"
            label-position="left"
          >
            <el-form-item ref="tenderNo" label="招标项目编号" prop="tenderNo">
              <el-input
                v-model.trim="searchForm.tenderNo"
                placeholder="招标项目编号"
                style="width:220px"
                @keyup.enter.native="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="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
              label="资格审查方式"
              prop="qualificationMethod"
            >
              <el-select v-model="searchForm.qualificationMethod" placeholder="请选择" style="width: 220px">
                <el-option
                  v-for="item in phaseTypeList"
                  :key="item.typecode"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </el-form-item>
            <el-form-item
              label="审核状态"
              prop="auditStatus"
            >
              <el-select v-model="searchForm.auditStatus" placeholder="请选择" style="width: 220px">
                <el-option
                  v-for="item in auditStatusOptions"
                  :key="item.typecode"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="创建日期">
              <el-date-picker
                v-model="createTime"
                type="daterange"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                style="width: 220px"
                @change="handleCreateTime"
              />
            </el-form-item>
          </el-form>
        </div>
        <div class="fr">
          <el-button type="primary" @click="onSearch">
            搜 索
          </el-button>
          <el-button plain type="info" @click="resetForm('searchForm')">
            重 置
          </el-button>
        </div>
      </div>
      <!--查询结果-->
      <div class="crud_menu_title">
        <span class="icon-line">查询结果</span>
      </div>
      <div>
        <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="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="buyersName"
            label="采购人名称"
            min-width="160"
          />
          <el-table-column
            header-align="center"
            prop="budgetTotalMoney"
            label="项目总概算"
            align="right"
            width="90"
          />
          <el-table-column
            header-align="center"
            label="认领状态"
            prop="claimType"
            align="center"
            width="90"
          >
            <template slot-scope="scope">
              {{ scope.row.claimType | filterClaimType }}
            </template>
          </el-table-column>
          <el-table-column
            label="项目标段数量"
            prop="projectPackageNum"
            align="right"
            width="100"
          />
          <el-table-column
            label="项目类型"
            prop="projectType"
            width="90"
          >
            <template slot-scope="scope">
              <span
                v-for="item in projectClassificationList"
                v-if="scope.row.projectType === item.typecode"
                :key="item.typecode"
              >{{ item.typename }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="资格审查方式"
            prop="qualificationMethod"
            width="100"
          >
            <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"
            label="操作"
            align="center"
            width="80"
          >
            <template slot-scope="scope">
              <el-link
                v-if="scope.row.claimType!=='01'"
                type="primary"
                @click.stop="claimProject(scope.row)"
              >
                [认领]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="loadData" />
      </div>
    </section>
  </div>
</template>
<script>
/* 接口*/
import { listClaimProjectPages } from '@/api/bidding/biddingProject'
/* 公用方法*/
import { filterObj } from '@/assets/js/utils'// 常用方法
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { initGroupMixin } from '@/mixins/initGroupMixin'// 字典信息
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页

export default {
  name: 'BidProjectClaimList',
  components: {
    pagination// 分页
  },
  filters: {
    filterClaimType(claimType) {
      const statusMap = {
        '': '未认领',
        '00': '未认领',
        '01': '已认领'
      }
      return statusMap[claimType]
    }
  },
  mixins: [ListMixin, initGroupMixin],
  data() {
    return {
      /* 字典信息-start */
      bidTypeList: [], // 招标方式
      phaseTypeList: [], // 资格审查方式
      /* 字典信息-end */
      loading: true,
      createTime: '',
      // 搜索
      searchForm: {
        auditStatus: '', // 审核状态 00:待审核 01:审核通过 02:审核不通过
        createBeginTime: '', // 创建开始时间
        createEndTime: '', // 创建结束时间
        qualificationMethod: '', // 00资格预审,01 资格后审
        tenderMethod: '', // 招标方式 : 公开招标 00 邀请招标 01 竞争性谈判 02 询价 03 单一来源采购 04 其他 05
        tenderName: '', // 项目名称
        tenderNo: '' // 项目编号
      },
      tableData: []
    }
  },
  created() {
    this.initGroup() // 获取字典方法
    // 获取列表信息
    this.loadData()
  },
  methods: {
    // 获取字典方法
    initGroup() {
      const data = [
        'bidType', // 招标方式
        'phaseType'// 资格审查方式
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 获取数据
    loadData() {
      const params = this.getQueryParams()// 查询条件
      listClaimProjectPages(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 认领项目
    claimProject(row) {
      this.$router.push({
        path: '/bidding/bidProjectClaimDetail',
        name: 'bidProjectClaimDetail',
        params: {
          id: row.tenderId
        }
      })
    },
    // 处理搜索时间格式
    handleCreateTime(val) {
      if (val) {
        this.searchForm.createBeginTime = this.$Moment(val[0]).format(this.momentDate)// 创建开始时间
        this.searchForm.createEndTime = this.$Moment(val[1]).format(this.momentDate)// 创建结束时间
      }
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      // 获取列表信息
      this.loadData()
    },
    // 重置
    resetForm(formName) {
      this.createTime = ''
      this.createTime = ''
      this.searchForm.createBeginTime = ''
      this.searchForm.createEndTime = ''
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.$refs[formName].resetFields()
      // 获取列表信息
      this.loadData()
    }
  }
}
</script>
<style lang="less" scoped>

</style>
