<!--
  @description:招标计划-公司级分配
  @Modifier: 肖文龙
  @routerPath: /tenderPlan/tenderPlanFirmClassAllot-list
  @date: 2020-6-2
-->
<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="124px"
            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.schemeBudget" placeholder="概算金额（元）" style="width:188px" />
            </el-form-item>
            <!--采购品类-->
            <el-form-item label="采购品类">
              <el-input v-model.trim="searchForm.purchaseClassName" style="width: 228px" @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-item label="创建时间">
              <el-date-picker
                v-model="searchForm.createUserDate"
                :format="elValueFormat"
                :value-format="elValueSaveFormat"
                type="daterange"
                range-separator="-"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                style="width:220px"
              />
            </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">
          <tenderPlanAllotComp ref="tenderPlanAllotComp" :search-form="searchForm" />
        </el-tab-pane>
        <el-tab-pane label="已分配" name="01">
          <tenderPlanalLocatedComp ref="tenderPlanalLocatedComp" :search-form="searchForm" />
        </el-tab-pane>
      </el-tabs>
    </section>
    <!-- 采购品类 -->
    <category-tree-dialog :dialog-data="dialogData" @categoryTreeInfo="categoryTreeInfo" />
  </div>
</template>

<script>
import { ListMixin } from '@/mixins/ListMixin'
import { tenderPlan } from '../../../mixins/tenderPlan'
/* 组件*/
import tenderPlanAllotComp from './tenderPlanAllotComp'// 未分配
import tenderPlanalLocatedComp from './tenderPlanalLocatedComp'// 已分配
import categoryTreeDialog from '@/views/common/tools/categoryTree-dialog'// 采购品类-弹框

export default {
  name: 'TenderPlanFirmClassAllotList',
  components: {
    tenderPlanAllotComp, // 未分配
    tenderPlanalLocatedComp, // 已分配
    'category-tree-dialog': categoryTreeDialog// 采购品类-弹框
  },
  mixins: [ListMixin, tenderPlan],
  data() {
    return {
      activeName: '00', // 默认选中第一个tab页 00未分配 01已分配
      // 弹窗-展示/隐藏状态 true 展示/false 隐藏
      dialogData: {
        title: '采购品类',
        dialog: false, // 采购品类
        selectCodes: [] // 当前选中的供货范围Code
      },
      searchForm: {
        assignedCompanyId: this.$store.getters.info.companyId, // 系统级分配公司id(必填，当前登录人组织机构id)
        schemeDeptname: '', // 招标人
        schemeName: '', // 招标计划名称(招标汇总名称）
        schemeNo: '', // 招标计划编号(招标汇总号)
        comAssignedStatus: '', // 公司级分配状态，00未分配，01已分配(必填)
        schemeBudget: '', // 概算金额元
        roundNum: 1, // 推送招标计划轮次 默认为1(必填1)
        purchaseClassName: '', // 采购品类
        purchasLevel: '', // 采购级别
        bidEvaluationMethod: '', // 评标办法
        purchaseCategory: '', // 采购类别
        purchasType: '', // 采购类型
        createTimeStart: '', // 创建开始时间
        createTimeEnd: '', // 创建结束时间
        createUserDate: []// 创建时间-不传给后端
      }
    }
  },
  watch: {
    // 创建时间
    'searchForm.createUserDate'(val) {
      this.searchForm.createTimeStart = val[0]// 创建开始时间
      this.searchForm.createTimeEnd = val[1]// 创建结束时间
    },
    // tab页切换时
    activeName(n) {
      this.onSearch()
    },
    // 采购品类
    'searchForm.purchaseClassName'(val) {
      if (!val) {
        this.dialogData.selectCodes = []
        return
      }
    }
  },
  created() {
    // 招标计划-字典信息
    this.initPurchaseSchemeWebTypeGroup()
  },
  mounted() {
    this.onSearch()
  },
  methods: {
    // 搜索
    onSearch() {
      // 未审核
      if (this.activeName === '00') {
        this.$refs.tenderPlanAllotComp.onSearch()
      }
      // 已审核
      if (this.activeName === '01') {
        this.$refs.tenderPlanalLocatedComp.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>
