<!--
  @description:自增计划列表
  @Modifier: sunxinman/haofengxian
  @routerPath:
  @date: 2020-5-22-14:12
-->
<template>
  <div>
    <el-button type="primary" class="mb10" @click="consignContractAdd()">
      添加招标计划
    </el-button>
    <section>
      <el-table
        ref="smallTable"
        v-loading="loading"
        :data="tableData"
        :row-key="getRowKeys"
      >
        <el-table-column
          fixed
          type="index"
          label="序号"
          align="center"
          width="60"
        />
        <el-table-column

          fixed
          prop="projectName"
          label="工程项目名称"
          min-width="230"
          header-align="center"
          align="left"
        />
        <el-table-column

          fixed
          prop="schemeDeptname"
          label="招标组织单位名称"
          min-width="300"
          header-align="center"
          align="left"
        />
        <el-table-column
          :formatter="formatPurchasLevel"
          header-align="center"
          prop="purchasLevel"
          label="采购级别"
          align="center"
          width="100"
        />
        <el-table-column
          prop="schemeNo"
          label="招标计划编号"
          width="160"
          header-align="center"
          align="left"
        />
        <el-table-column

          prop="schemeName"
          label="招标计划名称"
          min-width="230"
          header-align="center"
          align="left"
        />
        <el-table-column
          :formatter="formatBiddingOrganizationForm"
          header-align="center"
          prop="biddingOrganizationForm"
          label="招标组织形式"
          align="center"
          width="100"
        />
        <el-table-column

          header-align="center"
          prop="biddingAgencyName"
          label="招标代理机构"
          align="left"
          min-width="300"
        />
        <el-table-column
          :formatter="formatBiddingMethod"
          header-align="center"
          prop="biddingMethod"
          label="招标方式"
          align="center"
          width="100"
        />
        <el-table-column
          :formatter="formatQualificationCheckWay"
          header-align="center"
          prop="qualificationCheckWay"
          label="资格审查方式"
          width="100"
        />
        <el-table-column
          :formatter="formatSchemeClass"

          prop="schemeClass"
          label="工程分类"
          width="100"
        />
        <el-table-column

          prop="biddingClassSecondLevel"
          label="二级分类"
          min-width="110"
        >
          <template slot-scope="scope">
            <!--父级-->
            <span
              v-for="(item,index) in purchaseSchemeProjectTypeList"
              v-if="scope.row.biddingSchemeType === item.typecode"
              :key="index"
            >
              <!--子级-->
              <span
                v-for="(child,childIndex) in item.child"
                v-if="scope.row.biddingClassSecondLevel === child.typecode"
                :key="childIndex"
              >
                {{ child.typename }}
              </span>
            </span>
          </template>
        </el-table-column>
        <el-table-column
          :formatter="formatSchemeNature"
          prop="schemeNature"
          label="项目性质"
          align="center"
        />
        <el-table-column
          :formatter="formatBidOpeningMethod"
          prop="bidOpeningMethod"
          label="开标方式"
          align="center"
        />
        <el-table-column
          :formatter="schemeBudgetMoneyFormat"
          prop="schemeBudget"
          label="概算金额（元）"
          width="120"
          align="right"
        />
        <el-table-column
          :formatter="formatBiddingEvaluationWay"
          prop="biddingEvaluationWay"
          label="评标方式"
        />
        <el-table-column
          :formatter="formatBiddingQuotationMethod"
          prop="biddingQuotationMethod"
          label="投标报价方式"
          width="100"
        />
        <el-table-column
          fixed="right"
          label="操作"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <el-link type="primary" @click.stop="intoContract(scope.row.id)">
              [查看]
            </el-link>
            <el-link type="primary" @click.stop="change(scope.row.id)">
              [变更]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </section>
  </div>
</template>

<script>
/* api*/
import { getPretenderingPurchasesSchemePagesManager } from '@/api/purchasePlan/pretcloudPurchasescheme'
/* 组件*/
import pagination from '@comp/common/pagination/pagination' // 分页组件
/* 常用公共方法*/
import { filterObj } from '@/assets/js/utils'
/* 混入公共方法*/
import { ListMixin } from '@/mixins/ListMixin'
import { tenderPlan } from '../mixins/tenderPlan'
export default {
  name: 'BuildingProjectList',
  components: {
    pagination
  },
  mixins: [ListMixin, tenderPlan],
  data() {
    return {
      loading: true,
      tableData: [] // 自建项目列表
    }
  },
  created() {
    // 招标计划-字典信息
    this.initPurchaseSchemeWebTypeGroup()
    this.loadData()
  },
  methods: {
    // 获取row的key值
    getRowKeys(row) {
      return row.supplierID
    },
    // 查询条件
    getQueryParams(searchForm) {
      const param = Object.assign({}, searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 获取数据
    loadData(searchForm) {
      const params = this.getQueryParams(searchForm)// 查询条件
      params.createUser = this.$store.getters.info.id
      getPretenderingPurchasesSchemePagesManager(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 新增招标计划
    consignContractAdd() {
      this.$router.push({ path: '/tenderPlan/tenderPlanAdd' })
    },
    // 查看
    intoContract(id) {
      this.$router.push({
        name: 'TenderPlanBuildDetail',
        params: { id }
      })
    },
    // 变更
    change(id) {
      this.$confirm('变更招标计划可能会引起招标计划与立项信息不匹配，确认变更吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.$router.push({
          name: 'tenderPlanAddContent',
          params: { id }
        })
      }).catch(() => {

      })
    }
  }
}
</script>

<style lang="less" scoped>
</style>
