<!--
  @description: 集约化评标-待审批任务
  @author:肖文龙
  @routerPath:/intensiveeval/intensiveevalAudit-list
  @date: 2020年3月16日20:18:48
-->
<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>
      <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="schemeName" label="审批类型" prop="schemeName">
              <el-input v-model="searchForm.auditStatus1" width="228px" maxlength="200" placeholder="审批类型" />
            </el-form-item>
            <!--业务编号-->
            <el-form-item ref="schemeName" label="业务编号" prop="schemeName">
              <el-input v-model="searchForm.auditStatus1" width="228px" maxlength="200" placeholder="业务编号" />
            </el-form-item>
            <!--业务名称-->
            <el-form-item ref="schemeName" label="业务名称" prop="schemeName">
              <el-input v-model="searchForm.auditStatus1" width="228px" maxlength="200" placeholder="业务名称" />
            </el-form-item>
            <!--发起人-->
            <el-form-item ref="schemeName" label="发起人" prop="schemeName">
              <el-input v-model="searchForm.auditStatus1" width="228px" maxlength="200" placeholder="发起人" />
            </el-form-item>
            <!--招标人-->
            <el-form-item ref="schemeName" label="招标人" prop="schemeName">
              <el-input v-model="searchForm.auditStatus1" width="228px" maxlength="200" placeholder="招标人" />
            </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>
      <!--查询结果-->
      <div class="crud_menu_title">
        <span class="icon-line">查询结果</span>
      </div>

      <div :class="{'SearchContent_show':true}" class="clearfix SearchContent mb10">
        <el-button type="primary" @click="evaluationGroupAllAudit">
          批量审批通过
        </el-button>
      </div>

      <div>
        <el-table
          v-loading="loading"
          :data="tableData"
          @selection-change="selectionChange"
        >
          <el-table-column
            type="selection"
            width="45"
          />
          <el-table-column
            type="index"
            label="序号"
            width="45px"
            align="center"
          />
          <el-table-column
            prop="tenderNo"
            header-align="center"
            label="审批类型"
            width="140"
          />
          <el-table-column
            header-align="center"
            prop="tenderName"
            label="业务编号"
            width="140"
          />
          <el-table-column
            header-align="center"
            prop="tenderMethod"
            label="业务名称"
            min-width="200"
          />
          <el-table-column
            header-align="center"
            prop="tenderMethod"
            label="发起人"
            min-width="140"
          />
          <el-table-column
            header-align="center"
            prop="tenderMethod"
            label="提交时间"
            min-width="120"
          />
          <el-table-column
            header-align="center"
            label="操作"
            align="center"
            width="120"
          >
            <template slot-scope="scope">
              <el-link
                type="primary"
                @click="audit(scope.row)"
              >
                [审批]
              </el-link>
              <el-link
                type="primary"
                @click="progressSee(scope.row)"
              >
                [进度]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页 -->
        <pagination :pagination-data="paginationData" />
      </div>
    </section>
  </div>
</template>

<script>
/* api*/
import { queryIntensiveevalPlansToGroupPages, groupListAudit } 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'// 分页
export default {
  name: 'IntensiveevalAuditList',
  components: {
    pagination
  },
  mixins: [groupMixin, ListMixin],
  data() {
    return {
      loading: false, // 刷新loading
      searchForm: {
        auditStatus1: '', // 批次号
        auditStatus3: '', // 分组名称
        auditStatus: '', // 分组状态
        pageNo: 1,
        pageSize: 10
      },
      // 评标委员会列表
      tableData: [],
      // 已选中的评标委员会列表
      selectList: []
    }
  },
  created() {
    this.loadData()// 获取数据
  },
  methods: {
    // 审批
    audit(row) {
      this.$router.push(
        { path: '/intensiveeval/intensiveevalAudit-add',
          query: {
            groupId: row.id, // 分组Id
            batchNumber: row.batchNumber// 批次号
          }}
      )
    },
    /*
    * 当前选中的信息
    * val list
    * */
    selectionChange(val) {
      this.selectList = val
    },
    /*
    *批量提交审批通过
    * fromData 审批信息
    * */
    evaluationGroupAllAudit() {
      if (this.selectList.length > 0) {
        this.$confirm('当前选中' + this.selectList.length + '条，确认提交审批。', '提示', {
          confirmButtonClass: 'confirmBtn',
          cancelButtonClass: 'cancelBtn',
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          const data = {
            submitType: '01', // 00提交 01审核
            auditStatus: '01', // 审核状态 00审核中,01通过,02驳回;
            groupIds: []// 分组id集合
          }
          // 循环取分组id
          this.selectList.map(item => {
            data.groupIds.push(item.id)
          })
          data.groupIds = data.groupIds.join(',')// 转字符串逗号拼接
          groupListAudit(data).then(res => {
            this.$message({
              type: 'success',
              message: '提交成功'
            })
            // 清空已选择信息
            this.selectList = []
            this.$refs.smallTable.clearSelection()
            this.paginationData.pageNo = 1
            this.paginationData.pageSize = 10
            // 获取列表信息
            this.loadData()
          })
        }).catch(() => {
        })
      } else {
        this.$message({
          message: '必须选中一条记录。',
          type: 'warning'
        })
      }
    },
    // 进度
    progressSee() {
    },
    // 搜索
    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()// 查询条件
      queryIntensiveevalPlansToGroupPages(params).then(response => {
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
        for (let i = 0; i < this.tableData.length; i++) {
          this.tableData[i].createTime = this.$Moment(this.tableData[i].createTime).format('YYYY-MM-DD')
        }
        this.loading = false
      }).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" scoped>

</style>
