<template>
  <div>
    <el-row>
      <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="108px">
        <el-form-item label="投标项目名称" prop="projectName">
          <el-input v-model="queryParams.projectName" placeholder="请输入项目名称" clearable
            @keyup.enter.native="handleQuery()" />
        </el-form-item>
        <el-form-item label="招标业主" prop="partyA">
          <el-input v-model="queryParams.partyA" placeholder="请输入招标业主" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="投标时间" prop="tenderTime">
          <el-date-picker clearable v-model="queryParams.tenderTime" type="date" value-format="yyyy-MM-dd"
            placeholder="请选择投标时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery()">搜索</el-button>
        </el-form-item>
      </el-form>
    </el-row>

    <el-table ref="choosePTender" v-loading="loading" :data="tenderList" highlight-current-row
      @current-change="handleCurrentChange" :row-key="getRowKeys" @row-dblclick="confirmChoose">
      <!-- <el-table-column type="selection" width="50" align="center" :reserve-selection="true" /> -->
      <el-table-column label="投标项目名称" align="center" key="projectName" prop="projectName"
        :show-overflow-tooltip="true"  width="170px" />
      <el-table-column label="招标业主" align="center" prop="partyAName" min-width="100px" />
      <el-table-column label="招标代理" align="center" prop="agent" min-width="100px" />
      <el-table-column label="招标地点" align="center" prop="place" min-width="100px" />
      <el-table-column label="业主预算" align="center" prop="budget" min-width="100px" />
    </el-table>
    <div style="text-align: right;" class="mt20 mr20">
      <el-pagination @current-change="getList" :current-page.sync="queryParams.pageNum"
        :page-size="queryParams.pageSize" layout="total, prev, pager, next" :total="total">
      </el-pagination>
    </div>
    <div>
      已选项目：<el-tag>{{ choosePTender.projectName }}</el-tag>
    </div>
    <div style="text-align: center;margin-top: 20px;">
      <el-button type="primary" @click="confirmChoose">确认选择</el-button>
      <el-button @click="clearChoose">清空选择</el-button>
    </div>
  </div>
</template>

<script>
import { listProject, submitProject, modifyProject, delProject } from "@/api/oa/project/project";
import { listUser, getUser } from '@/api/system/user'
import { listTender, getTender } from "@/api/oa/tender/tender";
export default {
  props: {
  },
  data() {
    return {
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10
      },
      tenderList: [],
      userList: [],
      total: 0,
      loading: true,
      choosePTender: {
        projectName: ''
      }
    }
  },
  created() {
    this.getList();
    this.getUserList();
  },
  methods: {
    // 查询项目列表
    getList() {
      this.loading = true
      listTender(this.queryParams).then(response => {
        this.tenderList = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    /** 查询用户列表 */
    getUserList() {
      listUser({ pageNum: 1, pageSize: 9999 }).then(res => {
        this.userList = res.rows
      })
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    handleCurrentChange(val) {
      this.choosePTender = val
    },
    getRowKeys(row) {
      return row.tenderId;
    },
    confirmChoose() {
      this.$emit('choose', this.choosePTender)
    },
    clearChoose() {
      this.$refs.choosePTender.clearSelection();
    }
  },
}
</script>

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