<!--
  @description: 招标计划列表
  @author: sunxinman
  @routerPath:/tenderPlan/tenderPlanList
  @date: 2019-12-18 22:35:58
-->
<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>
      <section :class="{'SearchContent_show':toggleSearchStatus}" class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
          >
            <!--工程项目名称-->
            <el-form-item ref="projectName" label="工程项目名称" prop="projectName">
              <el-input v-model.trim="searchForm.projectName" placeholder="工程项目名称" />
            </el-form-item>
            <!--招标组织单位-->
            <el-form-item ref="schemeDeptname" label="招标组织单位" prop="schemeDeptname">
              <el-input v-model.trim="searchForm.schemeDeptname" placeholder="招标组织单位" />
            </el-form-item>
            <template v-if="toggleSearchStatus">
              <!--招标汇总名称-->
              <el-form-item ref="schemeName" label="招标汇总/计划名称" prop="schemeName">
                <el-input v-model.trim="searchForm.schemeName" placeholder="招标汇总/计划名称" />
              </el-form-item>
              <!--招标汇总号-->
              <el-form-item ref="schemeNo" label="招标汇总/计划编号" prop="schemeNo">
                <el-input v-model.trim="searchForm.schemeNo" placeholder="招标汇总/计划编号" />
              </el-form-item>
              <!--招标代理机构-->
              <el-form-item ref="biddingAgencyName" label="招标代理机构" prop="biddingAgencyName">
                <el-input v-model.trim="searchForm.biddingAgencyName" placeholder="招标代理机构" />
              </el-form-item>
              <!--招标项目类型-->
              <el-form-item ref="biddingSchemeType" label="招标项目类型" prop="biddingSchemeType">
                <el-input v-model.trim="searchForm.biddingSchemeType" placeholder="招标项目类型" />
              </el-form-item>
            </template>
          </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>
      </section>
      <el-tabs v-model="activeName">
        <el-tab-pane label="分配招标计划" name="00">
          <allocation-tenderPlan-list ref="allocationTenderPlan" />
        </el-tab-pane>
        <el-tab-pane v-if="isBiddingPlan" label="自增招标计划" name="01">
          <addSelf-tenderPlan-list ref="addSelfTenderPlan" />
        </el-tab-pane>
      </el-tabs>
    </section>
  </div>
</template>

<script>
/* 接口*/
import { selectIsCanSelfConstructionBiddingPlan } from '@api/common/user.js'

import { ListMixin } from '@/mixins/ListMixin'
/* 组件*/
import allocationTenderPlanList from './allocationTenderPlan-list'
import addSelfTenderPlanList from './addSelfTenderPlan-list'

export default {
  name: 'BuildingProjectList',
  components: {
    'allocation-tenderPlan-list': allocationTenderPlanList, // 分配招标计划列表
    'addSelf-tenderPlan-list': addSelfTenderPlanList // 自增招标计划列表
  },
  mixins: [ListMixin],
  data() {
    return {
      isBiddingPlan: true, // 是否可以自建计划
      activeName: '00', // 默认选中第一个tab页 00分配招标计划 01自增招标计划
      searchForm: {
        projectName: '', // 工程项目名称
        schemeDeptname: '', // 招标组织单位
        schemeName: '', // 招标汇总名称
        schemeNo: '', // 招标汇总号
        biddingAgencyName: '', // 招标代理机构
        biddingSchemeType: '', // 招标项目类型
        createUser: '',
        useStatus: ''
      }
    }
  },
  watch: {
    activeName() {
      this.onSearch()
    }
  },
  created() {
    this.getSelectIsCanSelfConstructionBiddingPlan()
  },
  methods: {
    // 查询当前登录人角色所处单位是否为代理机构单位(用于是否可自建招标计划---华能)
    getSelectIsCanSelfConstructionBiddingPlan() {
      selectIsCanSelfConstructionBiddingPlan().then(res => {
        this.isBiddingPlan = res.data
      }).catch(() => {
      })
    },
    // 搜索
    onSearch() {
      // 分配招标计划
      if (this.activeName === '00') {
        this.$refs.allocationTenderPlan.loadData(this.searchForm)
      }
      // 自增招标计划
      if (this.activeName === '01') {
        this.$refs.addSelfTenderPlan.loadData(this.searchForm)
      }
    },
    // 重置
    resetForm() {
      Object.keys(this.searchForm).forEach(val => {
        this.searchForm[val] = ''
      })
      this.onSearch()
    }
  }
}
</script>

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