<!--
  @description:招标方案审核
  @Modifier: haofengxian
  @routerPath: /bidInvitation/bidInvitationPlanAudit
  @date: 2020-6-1-19:56
-->
<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
            label-width="130px"
            label-position="left"
          >
            <!--招标人-->
            <el-form-item label="招标人">
              <el-input v-model.trim="searchForm.schemeDeptname" placeholder="招标人" style="width:220px" />
            </el-form-item>
            <!--招标汇总/计划名称-->
            <el-form-item label="招标汇总/计划名称">
              <el-input v-model.trim="searchForm.schemeName" placeholder="招标汇总/计划名称" style="width:220px" />
            </el-form-item>
            <!--招标汇总/计划号-->
            <el-form-item label="招标汇总/计划号">
              <el-input v-model.trim="searchForm.schemeNo" placeholder="招标汇总/计划号" style="width:220px" />
            </el-form-item>
            <el-form-item label="概算金额（元）">
              <el-input v-model.trim="searchForm.schemeBudget" placeholder="概算金额（元）" style="width:220px" />
            </el-form-item>
            <!--采购品类-->
            <el-form-item label="采购品类">
              <el-input v-model.trim="searchForm.purchaseClassName" style="width: 220px" @focus="dialogData.dialog=true" />
            </el-form-item>
            <!--采购级别-->
            <el-form-item label="采购级别">
              <el-select v-model="searchForm.purchasLevel" placeholder="请选择" style="width:220px">
                <el-option
                  v-for="(item,index) in purchaseSchemeLevelList"
                  :key="index"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </el-form-item>
            <!--评标办法-->
            <el-form-item label="评标办法">
              <el-select v-model="searchForm.bidEvaluationMethod" placeholder="请选择" style="width:220px">
                <el-option
                  v-for="(item,index) in purchasesSchemeProEvalMethodList"
                  :key="index"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </el-form-item>
            <!--采购类别-->
            <el-form-item label="采购类别">
              <el-select v-model="searchForm.purchaseCategory" placeholder="请选择" style="width:220px">
                <el-option
                  v-for="item in purchaseSchemeProjectTypeList"
                  :key="item.value"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </el-form-item>
            <!--采购类型-->
            <el-form-item label="采购类型">
              <el-select v-model="searchForm.purchasType" placeholder="请选择" style="width:220px">
                <el-option
                  v-for="item in purchaseSchemeTypeList"
                  :key="item.value"
                  :label="item.typename"
                  :value="item.typecode"
                />
              </el-select>
            </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>
      </section>
      <el-tabs v-model="activeName">
        <el-tab-pane label="未审核" name="00">
          <unBidInvitationPlanAuditComp ref="unBidInvitationPlanAuditComp" :search-form="searchForm" />
        </el-tab-pane>
        <el-tab-pane label="已审核" name="01">
          <advBidInvitationPlanAuditComp ref="advBidInvitationPlanAuditComp" :search-form="searchForm" />
        </el-tab-pane>
      </el-tabs>
    </section>
    <!-- 采购品类 -->
    <category-tree-dialog :dialog-data="dialogData" @categoryTreeInfo="categoryTreeInfo" />
  </div>
</template>

<script>
/* 混入 */
import { tenderPlan } from '../../../mixins/tenderPlan'
import { ListMixin } from '@/mixins/ListMixin'
/* 组件*/
import unBidInvitationPlanAuditComp from './unBidInvitationPlanAuditComp'
import advBidInvitationPlanAuditComp from './advBidInvitationPlanAuditComp'
import categoryTreeDialog from '@/views/common/tools/categoryTree-dialog'// 采购品类-弹框

export default {
  name: 'BidInvitationPlan',
  components: {
    unBidInvitationPlanAuditComp, // 未审核
    advBidInvitationPlanAuditComp, // 已审核
    'category-tree-dialog': categoryTreeDialog// 采购品类-弹框
  },
  mixins: [ListMixin, tenderPlan],
  data() {
    return {
      activeName: '00', // 默认选中第一个tab页 00未审核 01已审核
      // 弹窗-展示/隐藏状态 true 展示/false 隐藏
      dialogData: {
        title: '采购品类',
        dialog: false, // 采购品类
        selectCodes: [] // 当前选中的供货范围Code
      },
      searchForm: {
        schemeDeptname: '', // 招标人
        schemeName: '', // 招标计划名称(招标汇总名称）
        schemeNo: '', // 招标计划编号(招标汇总号)
        schemeSource: '01', // 系招标计划来源 00:系统内 01:系统外(必填:01)
        sysAssignedStatus: '', // 系统级审核状态，00未审核，01已审核(必填)
        schemeBudget: '', // 概算金额元
        roundNum: 1, // 推送招标计划轮次 默认为1(必填1)
        purchaseClassName: '', // 采购品类
        purchasLevel: '', // 采购级别
        bidEvaluationMethod: '', // 评标办法
        biddingOrganizationForm: '01', // 招标组织形式,“00”委托招标，“01”自行招标(必填:01)
        purchaseCategory: '', // 采购类别
        purchasType: '', // 采购类型
        useStatus: '01'// 使用状态 00临时,01正式,02作废(必填：01)
      }
    }
  },
  watch: {
    activeName(n) {
      this.onSearch()
    },
    // 采购品类
    'searchForm.purchaseClassName'(val) {
      if (!val) {
        this.dialogData.selectCodes = []
        return
      }
    }
  },
  created() {
    // 招标计划-字典信息
    this.initPurchaseSchemeWebTypeGroup()
  },
  mounted() {
    this.onSearch()
  },
  methods: {
    // 搜索
    onSearch() {
      this.searchForm.schemeSource = '01'// 系招标计划来源 00:系统内 01:系统外(必填:01)
      this.searchForm.biddingOrganizationForm = '01'//  招标组织形式,“00”委托招标，“01”自行招标(必填:01)
      this.searchForm.roundNum = 1// 推送招标计划轮次 默认为1(必填1)
      this.searchForm.useStatus = '01'// 使用状态 00临时,01正式,02作废(必填：01)
      // 未审核
      if (this.activeName === '00') {
        this.$refs.unBidInvitationPlanAuditComp.onSearch()
      }
      // 已审核
      if (this.activeName === '01') {
        this.$refs.advBidInvitationPlanAuditComp.onSearch()
      }
    },
    // 采购品类选择/清空
    categoryTreeInfo(data) {
      this.searchForm.purchaseClassName = data.labels
      this.dialogData.selectCodes = data.keys.split(',')
    },
    // 重置
    resetForm() {
      Object.keys(this.searchForm).forEach(val => {
        this.searchForm[val] = ''
      })
      this.onSearch()
    }
  }
}
</script>

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