<template>
  <div>
    <div style="margin-top:16px;text-align:right">
      <div class="flex-align-center flex-between mt-10">
        <el-input 
          style="width:200px" 
          size="small"  
          suffix-icon="el-icon-search" 
          v-model="param.content.where.condition" 
          placeholder="搜索" @keyup.enter.native="listData(param.content.pageNumber = 1)" @clear="listData(param.content.pageNumber = 1)" clearable></el-input>
      </div>
      <el-table
      :data="tableData"
      style="width: 100%;"
      size="mini"
      height="500px"
      border>
      <el-table-column
        prop="billno"
        label="合同编号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="title"
        label="合同标题"
        width="180">
      </el-table-column>
      <el-table-column
        prop="enterprisename"
        label="企业信息"
        width="180">
      </el-table-column>
      <el-table-column
        prop="projectname"
        label="项目名称"
        width="180">
      </el-table-column>
<!--      <el-table-column
        prop="type"
        label="项目类型"
        width="100">
      </el-table-column>-->
      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" @click="rowClick(scope.row)">选 择</el-button>
        </template>
      </el-table-column>
    </el-table>
      <el-pagination
        background
        small
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-size="param.content.pageSize"
        layout="total, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  props:['ismanage'],
  data () {
    return {
      param:{
        "id": 20230103150802,
        "content": {
          "pageNumber": 1,
          "pageSize": 20,
          "where": {
            "condition": ""
          }
        }
      },
      tableData: [],
      total:0,
      currentPage:0
    }
  },
  methods:{
    async listData () {
      if (this.ismanage) {
        this.param.content.ismanage = this.ismanage
      }
      const res = await this.$api.requested(this.param)
      this.tableData = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.param.content.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.param.content.pageNumber = val
      this.listData()
    },
    rowClick (row) {
      this.$emit('rowClick',row)
    }
  },
  created () {
    this.$emit('listCreate',this.param)
  },
  mounted () {
    this.listData()
  }
}

</script>
<style>
</style>