<template>
  <div>
    <div class="flex-align-center normal-margin">
      <el-input
          style="width:300px"
          placeholder="请输入内容"
          v-model="search"
          clearable
          @clear="clearData()"
          size="small"
          @keyup.enter.native="queryClick()">
        <i slot="prefix" class="el-icon-search" @click="queryClick()"></i>
      </el-input>
    </div>
    <tableLayout :layout="tablecols" :data="list" :opwidth="200" :custom="true"  :height="tableHieght" >
      <template v-slot:customcol="scope">
        <p>{{scope.column.data[scope.column.columnname]?scope.column.data[scope.column.columnname]:'--'}}</p>
      </template>
      <template v-slot:opreation="scope">
      </template>
    </tableLayout>
    <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>
</template>

<script>
export default {
  name: "list",
  props:["data"],
  data(){
    return {
      tableHieght:"600px",
      tablecols:[],
      list:[],
      total:0,
      currentPage:0,
      search:"",
      param:{
        "id": "20221018102003",
        "content": {
          "sys_enterpriseid":'',
          "type":1,
          "where":{
            "condition":""
          }

        }
      }
    }
  },
  methods:{
    async listData(){
      this.param.content.sys_enterpriseid = this.data.sys_enterpriseid
      const res = await this.$api.requested(this.param)
      this.list = 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()
    },
    onSuccess(){
      this.listData()
    },
    clearData(){
      this.search = ""
      this.queryClick()
    },
    queryClick(){
      this.param.content.where.condition = this.search
      this.listData()
    }
  },
  mounted() {
    this.listData()
  },
  created() {
    this.tablecols = this.tool.tabelCol(this.$route.name).projectChangeTable.tablecols
  },
}
</script>

<style scoped>
/deep/.el-input__prefix {
  display: flex;
  align-items: center;
}

</style>