
<template>
  <div>
    <div >
      <el-input
          placeholder="请输入搜索内容"
          suffix-icon="el-icon-search"
          v-model="params.content.where.condition"
          style="width:200px"
          size="small"
          class="input-with-select inline-16"
          @keyup.native.enter="listData()"
          @clear="clearData"
          clearable>
      </el-input>
    </div>
    <div style="margin-top: 15px">
      <tableLayout :layout="tablecols" :data="list" :opwidth="200"  :custom="true" :width="false"  :height="tableHieght" fixedName="operation">
        <template v-slot:customcol="scope">
          <p v-if="scope.column.columnname == 'leader'">
            <span v-if="scope.column.data[scope.column.columnname]">
              {{scope.column.data[scope.column.columnname][0].name}}
            </span>
            <span v-else>--</span>
          </p>
          <p v-else>{{scope.column.data[scope.column.columnname]}}</p>
          <p v-if="!scope.column.data[scope.column.columnname] && scope.column.columnname != 'leader'">--</p>
        </template>
        <template v-slot:opreation="scope">
        </template>
      </tableLayout>
    </div>
    <div style="margin-top:16px;text-align:right">
      <el-pagination
          background
          small
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="params.content.pageNumber"
          :page-size="params.content.pageSize"
          layout="total, prev, pager, next, jumper"
          :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  props:["data"],
  data () {
    return {
      tableHieght:"600px",
      tablecols:[],
      list:[],
      total:0,
      search:'',
      params:{
        "id": 20221124110002,
        "version": 1,
        "content": {
            "nocache": true,
            "pageNumber": 1,
            "pageSize":20,
            "sa_projectid": '',
            "where": {
                "condition": ""
            }
        },
      },
      options:[
      ],
      productList:''
    }
  },
  provide () {
    return {
    }
  },
  methods:{
    async listData(){
      this.params.content.sa_projectid = this.data.sa_projectid
      const res = await this.$api.requested(this.params)
      this.list = res.data
      this.total = res.total
      console.log(this.list)
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.params.content.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.params.content.pageNumber = val
      this.listData()
    },
    clearData(){
      this.search = ""
      this.params.content.where.condition = this.search
      this.listData()
    },
    queryClick(){
      this.params.content.where.condition = this.search
      this.listData()
    }
  },
  created() {
    this.listData()
    this.tablecols = this.tool.tabelCol(this.$route.name).ciueListTable.tablecols
  }
}

</script>
<style scoped>

</style>