<!--
  @description: 集约化评标明细列表
  @author:肖文龙
  @routerPath:/intensiveeval/intensiveevalPlanContent/intensiveevalDetail-list
  @date: 2020年3月12日12:03:49
-->
<template>
  <div>
    <!--查询条件-->
    <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-position="right"
        >
          <!--超过法定限额-->
          <el-form-item ref="beyondLegalLimit" label="超过法定限额" prop="beyondLegalLimit">
            <el-select v-model="searchForm.beyondLegalLimit" style="width: 228px" placeholder="请选择">
              <el-option v-for="(item,index) in exceedingLegalLimitList" :key="index" :label="item.typename" :value="item.typecode" />
            </el-select>
          </el-form-item>
          <!--招标项目类型-->
          <el-form-item ref="projectClassification" label="招标项目类型" prop="projectClassification">
            <el-select v-model="searchForm.projectClassification" style="width: 228px" placeholder="请选择">
              <el-option v-for="(item,index) in projectClassificationList" :key="index" :label="item.typename" :value="item.typecode" />
            </el-select>
          </el-form-item>
          <!--采购级别-->
          <el-form-item ref="purchaseLevel" label="采购级别" prop="purchaseLevel">
            <el-select v-model="searchForm.purchaseLevel" style="width: 228px" placeholder="请选择">
              <el-option v-for="(item,index) in purchaseLevelList" :key="index" :label="item.typename" :value="item.typecode" />
            </el-select>
          </el-form-item>
          <!--评标分组状态-->
          <el-form-item ref="groupedStatus" label="评标分组状态" prop="groupedStatus">
            <el-select v-model="searchForm.groupedStatus" style="width: 228px" placeholder="请选择">
              <el-option v-for="(item,index) in groupingStateList" :key="index" :label="item.typename" :value="item.typecode" />
            </el-select>
          </el-form-item>
          <!--资格预审项目-->
          <el-form-item ref="isQualificationProject" label="资格预审项目" prop="isQualificationProject">
            <el-select v-model="searchForm.isQualificationProject" style="width: 228px" placeholder="请选择">
              <el-option v-for="(item,index) in prequalificationProgramList" :key="index" :label="item.typename" :value="item.typecode" />
            </el-select>
          </el-form-item>
          <!--项目行业-->
          <el-form-item ref="industryName" label="项目行业" prop="industryName">
            <el-select v-model="searchForm.industryName" style="width: 228px" placeholder="请选择">
              <el-option v-for="(item,index) in projectIndustryList" :key="index" :label="item.typename" :value="item.typecode" />
            </el-select>
          </el-form-item>
          <!--评标办法-->
          <el-form-item ref="reviewWay" label="评标办法" prop="reviewWay">
            <el-select v-model="searchForm.reviewWay" style="width: 228px" placeholder="请选择">
              <el-option v-for="(item,index) in evaluationTypeList" :key="index" :label="item.typename" :value="item.typecode" />
            </el-select>
          </el-form-item>
          <!--评标委员会组建方式-->
          <el-form-item ref="juryBuildType" label-width="140px" label="评标委员会组建方式" prop="juryBuildType">
            <el-select v-model="searchForm.juryBuildType" style="width: 184px" placeholder="请选择">
              <el-option v-for="(item,index) in juryOrganizeWayList" :key="index" :label="item.typename" :value="item.typecode" />
            </el-select>
          </el-form-item>
        </el-form>
      </div>
      <div class="fr">
        <el-button type="primary" size="small" @click="onSearch">
          搜索
        </el-button>
        <el-button plain type="info" size="small" @click="resetForm('searchForm')">
          重置
        </el-button>
      </div>
    </div>
    <!--操作按钮-->
    <section
      :class="{'SearchContent_show':true}"
      style="margin-top: 10px"
      class="clearfix SearchContent"
    >
      <el-button
        type="primary"
        @click="dialogData.dialog=true"
      >
        获取集约化评标计划
      </el-button>
      <el-button
        v-if="tableData.length>0"
        type="primary"
        @click="fillInGroupNameAllInfo()"
      >
        批量填写分组名称
      </el-button>
      <el-button
        v-if="tableData.length>0"
        @click="refresh"
      >
        刷新
      </el-button>
      <el-button
        style="color: red;font-size:14px;"
        type="text"
      >
        当前共{{ tableDataInfo.total }}条记录，未填写分组名称{{ tableDataInfo.notFilledGroupNameCount }}条，新增{{
          tableDataInfo.addPlanCount }}条，减少{{
          tableDataInfo.lessenPlanCount }}条。
      </el-button>
    </section>
    <!--列表-->
    <section style="margin-top: 10px;">
      <el-table
        ref="smallTable"
        v-loading="loading"
        :data="tableData"
        :row-class-name="rowClassName"
        @selection-change="selectionChange"
      >
        <el-table-column
          :selectable="isDisabled"
          type="selection"
          width="45"
        />
        <el-table-column
          type="index"
          label="序号"
          fixed="left"
          width="45px"
          align="center"
        />
        <el-table-column
          prop="tenderName"
          header-align="center"
          label="招标项目名称"
          fixed="left"
          width="300"
        />
        <el-table-column
          header-align="center"
          prop="packNo"
          fixed="left"
          label="标段（包）编号"
          min-width="200"
        />
        <el-table-column
          align="center"
          prop="juryBuildType"
          label="评标委员会组建方式"
          min-width="130"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in juryOrganizeWayList"
              v-if="scope.row.juryBuildType===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="purchaseLevel"
          label="采购级别"
          min-width="70"
          align="center"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in purchaseLevelList"
              v-if="scope.row.purchaseLevel===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="projectClassification"
          label="招标项目类型"
          min-width="100"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in projectClassificationList"
              v-if="scope.row.projectClassification===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          align="center"
          prop="beyondLegalLimit"
          label="超过法定限额"
          min-width="100"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in exceedingLegalLimitList"
              v-if="scope.row.beyondLegalLimit===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="reviewWay"
          label="评标办法"
          min-width="140"
          align="center"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in evaluationTypeList"
              v-if="scope.row.reviewWay===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          prop="isQualificationProject"
          label="资格预审项目"
          min-width="100"
          align="center"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in prequalificationProgramList"
              v-if="scope.row.isQualificationProject===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="评委会是否分组"
          prop="judgesGroupedStatus"
          min-width="110"
          align="center"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in judgingPanelTypeList"
              v-if="scope.row.judgesGroupedStatus===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="开标日期"
          prop="openBidStartTime"
          align="center"
          min-width="130"
        >
          <template slot-scope="scope">
            {{ scope.row.openBidStartTime && $Moment(scope.row.openBidStartTime).format(momentDateTime) }}
          </template>
        </el-table-column>
        <el-table-column
          label="项目行业"
          prop="industryName"
          align="center"
          min-width="70"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in projectIndustryList"
              v-if="scope.row.industryName===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="开标计划状态"
          prop="openBidPlanStatus"
          align="center"
          min-width="100"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in openingScheduleStatusList"
              v-if="scope.row.openBidPlanStatus===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="评标分组状态"
          prop="groupedStatus"
          align="center"
          min-width="110"
        >
          <template slot-scope="scope">
            <span
              v-for="(item,index) in groupingStateList"
              v-if="scope.row.groupedStatus===item.typecode"
              :key="index"
            >{{ item.typename }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="分组名称"
          prop="groupName"
          header-align="center"
          min-width="200"
        />
        <el-table-column
          header-align="center"
          label="操作"
          align="center"
          fixed="right"
          width="230"
        >
          <template slot-scope="scope">
            <!--
            “开评标计划状态”为 02新增和 01 正常 &&
             (评标分组状态为：00 未分组 || 01 评标分组待编辑 ||02 评标分组已保存 || 05 评标分组审批不通过)
            -->
            <el-link
              v-if="scope.row.openBidPlanStatus!=='00'&&(scope.row.groupedStatus==='00'||scope.row.groupedStatus==='01'||scope.row.groupedStatus==='02'||scope.row.groupedStatus==='05')"
              type="primary"
              @click="editGrouping(scope.row)"
            >
              [填写分组名称]
            </el-link>
            <!--
            开评标计划状态 00 减少 ||(“开评标计划状态”为 02新增和 01 正常 &&(评标分组状态为：03 评标分组待审批 || 04 评标分组审批通过 || 06 已指定牵头人 || 07 已创建评委会信息 ||
            08 已抽取完成))
            -->
            <el-link
              v-if="scope.row.openBidPlanStatus==='00'||
                (scope.row.openBidPlanStatus!=='00'&&(scope.row.groupedStatus==='03'||scope.row.groupedStatus==='04'||scope.row.groupedStatus==='06'||scope.row.groupedStatus==='07'||scope.row.groupedStatus==='08'))"
              type="primary"
              @click="seeGrouping(scope.row)"
            >
              [查看分组名称]
            </el-link>
            <el-link
              type="primary"
              @click="seeChangeInfo(scope.row)"
            >
              [查看变更信息]
            </el-link>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <pagination :pagination-data="paginationData" @change="loadData" />
    </section>
    <!--获取集约化评标计划弹框-->
    <getIntensiveevalDetailDialog :dialog-data="dialogData" @getIntensiveevalDetailInfo="getIntensiveevalDetailInfo" />
    <!--批量填写分组名称-->
    <fillInGroupNameAllDialog :dialog-data="fillInGroupNameAllInfoDialog" @fillInGroupNameAllInfo="fillInGroupNameAllInfo" />
  </div>
</template>

<script>
/* api*/
import {
  queryTimeByUserId,
  queryIntensiveevalListByTimePages,
  addIntensiveevalPlansToGroup,
  queryIntensiveevalListByConditionPages,
  getStatisticsDate } from '@/api/intensiveeval/intensiveeval'
/* 混合开发*/
import { groupMixin } from '@/views/intensiveeval/mixins/intensiveevalGroupMixin'// 字典信息
import { ListMixin } from '@/mixins/ListMixin'// 分页
/* 公用方法*/
import { filterObj } from '@/assets/js/utils'// 常用方法
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
import getIntensiveevalDetailDialog from './getIntensiveevalDetail-dialog'// 获取集约化评标计划
import fillInGroupNameAllDialog from '../fillInGroupName/fillInGroupNameAll-dialog'// 批量填写分组名称
export default {
  name: 'EvaluationDetailsList',
  components: {
    pagination,
    getIntensiveevalDetailDialog,
    fillInGroupNameAllDialog
  },
  mixins: [groupMixin, ListMixin],
  data() {
    return {
      loading: false, // 刷新loading
      searchForm: {
        beyondLegalLimit: '', // 超过法定限额(00否 01是)
        industryName: '', // 项目行业 （火电，风电，光伏）
        isQualificationProject: '', // 资格预审项目 00否 01是
        groupedStatus: '', // 分组状态(00未分组 01评标分组待编辑 02评标分组已保存 03评标分组待审批 04评标分组审批通过 05评标分组审批驳回 06已指定牵头人 07已创建评委会申请 08已抽取完成)
        juryBuildType: '', // 评标委员会组建方式(00随机抽取 01直接指定)
        projectClassification: '', // 招标项目类型 01工程 02货物 03服务
        purchaseLevel: '', // 采购级别 00一级 01二级 02三级
        reviewWay: '', // 评标方式 00: 有效最低价 01:综合评估法
        pageNo: 1, //
        pageSize: 10
      },
      // 获取集约化评标计划
      dialogData: {
        dialog: false
      },
      // 批量填写分组名称
      fillInGroupNameAllInfoDialog: {
        dialog: false
      },
      // 评标委员会列表信息
      tableDataInfo: {
        total: 0, // 共几条记录
        addPlanCount: 0, // 新增了几条记录
        lessenPlanCount: 0, // 减少了几条记录
        notFilledGroupNameCount: 0// 未填写分组名称几条记录
      },
      // 评标委员会列表
      tableData: [],
      // 已选中的评标委员会列表
      selectList: []
    }
  },
  created() {
    this.initWebTypeGroup()// 集约化评标计划-集约化评标明细(立项-字典信息)
    this.getQueryAllDepartPage()// 查询集约化评标所有的部门
    this.loadData()
    // 首页列表统计数据
    this.getStatistics()
  },
  methods: {
    /*
    * 查看变更信息
    * row当前选中的信息
    * */
    seeChangeInfo(row) {
      this.$router.push({
        path: '/intensiveeval/intensiveevalDetailChangeInfo-detail',
        query: {
          planId: row.planId// 评标计划Id
        }
      })
    },
    /*
    * 填写分组信息
    * row当前选中的信息
    * */
    editGrouping(row) {
      this.$router.push({
        path: '/intensiveeval/fillInGroupName-add',
        query: {
          planId: row.planId// 评标计划Id
        }
      })
    },
    /*
    * 查看分组信息
    * row当前选中的信息
    * */
    seeGrouping(row) {
      this.$router.push({
        path: '/intensiveeval/fillInGroupName-detail',
        query: {
          planId: row.planId// 评标计划Id
        }
      })
    },
    /*
    * talbe表格行的 className 的回调方法，也可以使用字符串为所有行设置一个固定的 className
    * row当前行的参数
    * */
    rowClassName({ row }) {
      if (row.openBidPlanStatus === '00') { // 减少
        return 'intensiveevalPlan_table-row-reduce-color'
      } else if (row.openBidPlanStatus === '02') { // 新增
        return 'intensiveevalPlan_table-row-added-color'
      }
    },
    // 复选框部分禁用
    isDisabled(row, index) {
      if (row.openBidPlanStatus !== '00' && (row.groupedStatus === '00' || row.groupedStatus === '01' || row.groupedStatus === '02' || row.groupedStatus === '05')) {
        /*
        * “开评标计划状态”为 02新增和 01 正常 &&
        * (评标分组状态为：00 未分组 || 01 评标分组待编辑 ||02 评标分组已保存 || 05 评标分组审批不通过)
        * */
        return true
      } else if (row.openBidPlanStatus === '00' || (row.openBidPlanStatus !== '00' && (row.groupedStatus === '03' || row.groupedStatus === '04' || row.groupedStatus === '06' || row.groupedStatus === '07' || row.groupedStatus === '08'))) {
        /*
        * 开评标计划状态 00 减少 ||
        * (“开评标计划状态”为 02新增和 01 正常 &&(评标分组状态为：03 评标分组待审批 || 04 评标分组审批通过 || 06 已指定牵头人 || 07 已创建评委会信息 ||08 已抽取完成))
        * */
        return false
      }
    },
    /*
    * 当前选中的信息
    * val list
    * */
    selectionChange(val) {
      this.selectList = val
    },
    /*
    *批量填写分组名称
    * fromData 批量分组名称
    * */
    fillInGroupNameAllInfo(fromData) {
      if (fromData) { // 确定提交批量审批
        this.selectList.forEach(item => {
          fromData.planIds.push(item.planId)// 评标计划id集合
        })
        fromData.planIds = fromData.planIds.join(',')// 评标计划id集合
        addIntensiveevalPlansToGroup(fromData).then(res => {
          this.selectList = [] // 初始化清空
          this.$refs.smallTable.clearSelection()// 取消选择
          this.onSearch()// 搜索
        })
      } else { // 选择要审批的信息
        if (this.selectList.length > 0) {
          this.fillInGroupNameAllInfoDialog.dialog = true// 打开弹窗
        } else {
          this.$message({
            message: '必须选中一条记录。',
            type: 'warning'
          })
        }
      }
    },
    // 刷新
    refresh() {
      // 查询上次获取的时间
      queryTimeByUserId().then(res => {
        const data = {
          evaluationStartTime: res.data.startTime, // 评标开始时间
          evaluationEndTime: res.data.endTime, // 评标结束时间
          gainPlanMethod: '00' // 获取计划方式(00重新获取,对比原数据 01重新获取,删除原数据)
        }
        this.getIntensiveevalDetailInfo(data)// 获取集约化评标计划列表
      })
    },
    /*
    * 获取集约化评标计划列表
    * data 查询参数信息
    * */
    getIntensiveevalDetailInfo(data) {
      queryIntensiveevalListByTimePages(data).then(res => {
        this.onSearch()// 搜索
      })
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      // 获取列表信息
      this.loadData()
    },
    // 重置
    resetForm(formName) {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      this.$refs[formName].resetFields()
      // 获取列表信息
      this.loadData()
    },
    // 获取数据
    loadData() {
      this.loading = true
      const params = this.getQueryParams()// 查询条件
      queryIntensiveevalListByConditionPages(params).then(response => {
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
        this.tableDataInfo.total = response.data.total
        this.loading = false
      }).catch(() => {

      })
    },
    getStatistics() {
      const params = this.getQueryParams()// 查询条件
      getStatisticsDate(params).then(res => {
        // 新增了几条记录
        this.tableDataInfo.addPlanCount = res.data.addPlanCount
        // 减少了几条记录
        this.tableDataInfo.lessenPlanCount = res.data.lessenPlanCount
        // 未填写分组名称几条记录
        this.tableDataInfo.notFilledGroupNameCount = res.data.notFilledGroupNameCount
      }).catch(() => {

      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    }
  }
}
</script>

<style lang="less">

  /*talbeList列表新增样式*/
  .el-table tr.intensiveevalPlan_table-row-added-color{
    font-weight: bold;
  }
  /*talbeList列表减少样式*/
  .el-table tr.intensiveevalPlan_table-row-reduce-color{
    color: #999;
  }
</style>
