
<!--
  @description: 部门经理-中选审核列表
  @author: wxy/gmy
  @routerPath:/procurement/procurementAuditList
  @date：2020-07-14 17:02:00
-->
<template>
  <div>
    <table-crud
      ref="tableCrud"
      :menu="true"
      :search-form="searchForm"
      :tabs="tabList"
      search-label-width="100px"
      @on-load="loadData"
    >
      <!--标题-->
      <template v-slot:header>
        <span>中选审核</span>
      </template>
      <!--查询条件-->
      <template v-slot:search="search">
        <!--采购单编号-->
        <el-form-item ref="orderCode" label="采购单编号" class="el-form-item--two" prop="tenderNo">
          <el-input
            v-model.trim="searchForm.tenderNo"
            placeholder="采购单编号"
            style="width:20vw"
            @keyup.enter.native="search.onSearch"
          />
        </el-form-item>
        <!--报价截止时间-->
        <el-form-item ref="date" label="报价截止时间" prop="date">
          <el-date-picker
            v-model="searchForm.quoteEndTimeBegin"
            :default-time="defaultTimeDateTime"
            :value-format="elValueSaveFormat"
            :clearable="false"
            type="datetime"
            placeholder="开始时间"
            style="width: 200px"
          />~
          <el-date-picker
            v-model="searchForm.quoteEndTimeEnd"
            :default-time="defaultTimeDateTime"
            :value-format="elValueSaveFormat"
            :clearable="false"
            type="datetime"
            placeholder="结束时间"
            style="width: 200px;"
          />
        </el-form-item>
        <!--提交人-->
        <el-form-item ref="submitter" label="提交人" class="el-form-item--two" prop="submitter">
          <el-input
            v-model.trim="searchForm.submitter"
            placeholder="提交人"
            style="width:20vw"
            @keyup.enter.native="search.onSearch"
          />
        </el-form-item>
        <!--提交时间-->
        <el-form-item ref="date" label="提交时间" prop="date">
          <el-date-picker
            v-model="searchForm.submitterTimeBegin"
            :default-time="defaultTimeDateTime"
            :value-format="elValueSaveFormat"
            :clearable="false"
            type="datetime"
            placeholder="开始时间"
            style="width: 200px"
          />~
          <el-date-picker
            v-model="searchForm.submitterTimeEnd"
            :default-time="defaultTimeDateTime"
            :value-format="elValueSaveFormat"
            :clearable="false"
            type="datetime"
            placeholder="结束时间"
            style="width:200px"
          />
        </el-form-item>
        <!--采购单名称-->
        <el-form-item
          ref="tenderName"
          label="采购单名称"
          class="el-form-item--two"
          prop="tenderName"
        >
          <el-input
            v-model.trim="searchForm.tenderName"
            placeholder="采购名称"
            style="width:20vw"
            @keyup.enter.native="search.onSearch"
          />
        </el-form-item>
      </template>
      <!-- <template v-slot:menuLeft> -->
      <!-- <div v-if="serchForm.auditStatus === '00'" style="padding-bottom:10px"> -->
      <!--        <el-button type="primary" @click="patchAuditIs">-->
      <!--          批量审核-->
      <!--        </el-button>-->
      <!-- </div> -->
      <!-- </template> -->
      <template v-slot:GXTable>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
          @selection-change="patchAudit"
        >
          <!-- <el-table-column
            v-if="searchForm.auditStatus === '00'"
            :selectable="checkbox"
            type="selection"
            width="60"
            align="center"
          /> -->
          <el-table-column type="index" label="序号" align="center" width="60" />
          <el-table-column
            prop="tenderNo"
            label="采购单编号"
            header-align="center"
            align="center"
            min-width="120"
          />
          <el-table-column
            prop="tenderName"
            label="采购单名称"
            header-align="center"
            align="left"
            min-width="180"
          />
          <el-table-column label="报价截止时间" min-width="160" header-align="center" align="center">
            <template slot-scope="scope">
              <p v-if="scope.row.quoteEndTime">
                {{ $Moment(scope.row.quoteEndTime).format(momentDateTime) }}
              </p>
            </template>
          </el-table-column>
          <el-table-column
            prop="offerSupplierNum"
            label="报价供应商数"
            min-width="80"
            header-align="center"
            align="right"
          />
          <el-table-column
            prop="submitter"
            label="提交人"
            min-width="120"
            header-align="center"
            align="left"
          />
          <el-table-column label="提交日期" align="center" min-width="160" header-align="center">
            <template slot-scope="scope">
              <span>{{ $Moment(scope.row.submitterTime).format(momentDateTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" min-width="150">
            <template slot-scope="scope">
              <!-- 订单状态  00  待审核  -->
              <el-link
                v-if="scope.row.auditStatus==='00'"
                type="primary"
                @click.stop="edit(scope.row)"
              >
                [审核]
              </el-link>
              <el-link v-else type="primary" @click.stop="detail(scope.row)">
                [查看]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </table-crud>
    <!-- 审核弹框 -->
    <auditDialog :key="new Date()*1" :dialog-data="dialogData" />
  </div>
</template>

<script>
/* api接口*/
import { queryAuditWinningResultList } from '@/api/procurement/procurementResult'
/* 公共参数方法*/
import { commonMxin } from '@/mixins/commonMxin'
import { orderManagementGroupMixin } from '../mixins/orderManagementGroupMixins'
// import { filterObj } from '@/assets/js/utils'
/* 分页组件*/
import auditDialog from '../procurementWinningAudit/procurementWinningAudit-dialog' // 审核弹框
export default {
  name: 'OrderManagementList',
  components: {
    auditDialog // 审核弹框
  },
  mixins: [commonMxin, orderManagementGroupMixin],
  data() {
    return {
      loading: true,
      // 中选审核状态
      tabList: [
        { index: '00', name: '待审核' },
        { index: '01', name: '审核通过' },
        { index: '02', name: '审核驳回' },
        { index: '03', name: '全部' }
      ],
      searchForm: {
        auditStatus: '00', // 审核状态 00待审核 01审核通过 02审核驳回 03 全部 默认00
        quoteEndTimeBegin: '', // 报价截止时间的开始输入时间
        quoteEndTimeEnd: '', // 报价截止时间的结束输入时间
        submitter: '', // 提交人
        submitterTimeBegin: '', // 提交时间的开始时间
        submitterTimeEnd: '', // 提交时间的结束时间
        tenderName: '', // 采购单名称
        tenderNo: '' // 采购单编号
      },
      // activeName: '00', // 订单状态状态
      tableData: [], // 订单信息列表
      multipleSelection: [], // 批量审核 选中记录存放数组
      dialogData: {
        // 批量审核-弹框
        winningIds: '', // 采购单结果主键id集合
        dialog: false
      },
      orderIds: '' // 多个报名id以,隔开拼接的字符串
    }
  },
  watch: {
    'dialogData.dialog'(val) {
      if (!val) {
        this.$refs.tableCrud.onSearchChange()
      }
    }
  },
  created() {
  },
  methods: {
    // 获取数据
    loadData(params, callback, tabData) {
      if (tabData) {
        params.auditStatus = tabData.index
        this.searchForm.auditStatus = tabData.index
      }
      queryAuditWinningResultList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        callback(response.data.total)
      }).catch(() => {
        this.loading = false
      })
    },
    // 查看
    detail(row) {
      if (row.tenderMethod === '14') {
        // 竞价审核页面
        this.$router.push({
          name: 'procurementAuditComprehensiveDetail',
          params: {
            stageId: row.stageId, // 项目轮次id
            packId: row.packId, // 项目标段id
            tenderId: row.tenderId, // 项目id
            auditStatus: row.auditStatus, // 状态
            winningId: row.winResultId, // 中选id
            tenderName: row.tenderName // 项目名称
          }
        })
      } else {
        // 查看页面
        this.$router.push({
          path: '/procurement',
          name: 'procurementAuditLowestDetail',
          params: {
            stageId: row.stageId, // 项目轮次id
            packId: row.packId, // 项目标段id
            tenderId: row.tenderId, // 项目id
            auditStatus: row.auditStatus, // 状态
            winningId: row.winResultId, // 中选id
            tenderName: row.tenderName // 项目名称
          }
        })
      }
    },
    // 批量审核选择
    patchAudit(val) {
      this.multipleSelection = val
    },
    // 批量审核弹框
    patchAuditIs() {
      if (!this.multipleSelection.length) {
        this.$message({
          type: 'warning',
          message: '请选择需要审核的数据'
        })
        return
      }
      // 获取中选数据id集合
      const arr = []
      this.multipleSelection.forEach(val => {
        arr.push(val.winResultId)
      })
      this.dialogData.winningIds = arr.toString()
      this.dialogData.dialog = true
    },
    // 审核
    edit(row) {
      // 竞价审核页面
      if (row.tenderMethod === '14') {
        this.$router.push({
          name: 'procurementComprehensiveAuditAdd',
          params: {
            stageId: row.stageId, // 项目轮次id
            packId: row.packId, // 项目标段id
            tenderId: row.tenderId, // 项目id
            auditStatus: row.auditStatus, // 状态
            winningId: row.winResultId, // 中选id
            tenderName: row.tenderName // 项目名称
          }
        })
      } else {
        // 审核页面
        this.$router.push({
          name: 'procurementLowestAuditAdd',
          params: {
            stageId: row.stageId, // 项目轮次id
            packId: row.packId, // 项目标段id
            tenderId: row.tenderId, // 项目id
            auditStatus: row.auditStatus, // 状态
            winningId: row.winResultId, // 中选id
            tenderName: row.tenderName // 项目名称
          }
        })
      }
    },
    // 复选框状态
    checkbox(row) {
      if (row.isLeader === '01') {
        return false
      } else {
        return true
      }
    }
  }
}
</script>

<style lang="less" scoped>
/deep/ .el-date-editor.el-input {
  width: 204px;
}
</style>

