<template>
  <div>
      <el-input placeholder="请输入编号/项目名称"  suffix-icon="el-icon-search" @input="listData(params.content.pageNumber = 1)" v-model="params.content.where.condition" @keyup.native.enter="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" style="width:300px;margin-bottom: 20px" size="small" class="input-with-select inline-16" clearable>
      </el-input>
    <el-table
        :data="list"
        style="width: 100%"
        size="mini"
        border>
      <el-table-column
          prop="projectnum"
          label="项目编号"
          width="180">
      </el-table-column>
      <el-table-column
          prop="projectname"
          label="项目名称"
          width="180">
      </el-table-column>
      <el-table-column
          prop="address"
          label="项目地址">
      </el-table-column>
      <el-table-column
          label="操作"
          width="90">
        <template slot-scope="scope">
          <el-button type="text" size="mini" @click="addProject(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="params.content.pageSize"
            :page-sizes="[20, 50, 100, 200]"
            layout="total,sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </div>
  </div>
</template>

<script>
import layout_table from '../projectAdd/table'
export default {
  name: "project",
  props:["visible"],
  data(){
    return {
      dialogProjectVisible:false,
      bill_id:"",
      tablecols:[],
      list:[],
      total:0,
      currentPage:0,
      row:"",
      params:{
        "id": 20220905151902,
        "content": {
          "where": {
            "condition": ""
          }
        },
      }
    }
  },
  components:{layout_table},
  mounted() {
    console.log(this.visible)
    this.dialogProjectVisible = true
    this.listData()
  },
  methods:{
    async listData(){
      const res = await this.$api.requested(this.params)
      this.list = res.data
      this.total = res.total
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.params.content.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.params.content.pageNumber = val
      this.listData()
    },
    onColes(){
      this.dialogProjectVisible = false
      this.$emit("onProject")
    },
    onRow(row){
      console.log("**********************---------------------")
      console.log(row)
      this.row = row
    },
    onSubmit(){
      console.log("**********************---------------------")
      this.dialogProjectVisible = false
      this.$emit("onProject",this.row)
      console.log(this.row)
    },
    addProject(val){
      console.log(val,"选择的项目")
      this.$emit("onProject",val)
    }

  },

  /*created() {
    this.tablecols = this.tool.tabelCol(this.$route.name).projectTable.tablecols
  }*/
}
</script>

<style scoped>

</style>