<template>
  <div>
     <el-popover
      placement="bottom"
      width="100%"
      :disabled="!id"
      v-model="visible">
      <div>
        <div class="flex-align-center flex-between" style="margin-bottom:10px">
          <el-input style="width:200px" suffix-icon="el-icon-search" size="small" 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"
          border>
          <el-table-column
            prop="sonum"
            label="订单编号"
            width="180">
          </el-table-column>
          <el-table-column
            prop="type"
            label="订单类型"
            width="180">
          </el-table-column>
          <el-table-column
            prop="tradefield"
            label="领域"
            width="180">
          </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>
        <div style="margin-top:16px;text-align:right">
          <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>
      <el-input readonly :validate-event="false" slot="reference" v-model="form.sonum" @focus="listData" :disabled="!id" placeholder="订单信息" clearable></el-input>
     </el-popover>
  </div>
</template>

<script>
export default {
  props:['id'],
  data () {
    return {
      visible:false,
      param:{
        "id": 20230116134402,
        "content": {
          "sa_contractid": 0,
          "pageSize": 20,
          "pageNumber":1,
          "where": {
            "condition": ""
          }
        },
      },
      
      form:{sonum:''},
      tableData: [],
      total:0,
      currentPage:0
    }
  },
  methods:{
    async listData () {
      console.log(this.id)
      this.param.content.sa_contractid = this.id
      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.form.sonum = row.sonum
      this.visible = false
      this.$emit('orderRowClick',row)
    }
  },
  mounted () {
  }
}

</script>
<style>
</style>