<template>
  <div >
<!--    <div class="flex-align-center normal-margin">
      <add class="inline-16" :data="data" @onSuccess="listData" ></add>
      <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"  >
      <template v-slot:customcol="scope">
        <p>{{scope.column.data[scope.column.columnname]}}</p>
      </template>
      <template v-slot:opreation="scope">
        <edit v-if="tool.checkAuth($route.name,'clueManage')" :data="scope.data" @onSuccess="listData"></edit>
      </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>
import add from './modules/add'
import edit from './modules/edit'

export default {
  name: "index",
  props:["data"],
  components:{add,edit},
  data(){
    return {
      tablecols: [],
      list: [],
      total: 0,
      currentPage: 0,
      search:'',
      param: {
        "id": 20221208163302,
        "content": {
          "sa_customersid": 1,
          "pageNumber": 1,
          "pageSize": 20,
          "where": {
            "condition": ""
          }
        }
      }
    }
  },
  methods:{
    async listData(){
      this.param.content.sa_customersid = this.data.sa_customersid
      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()
    },
    clearData(){
      this.search = ""
    },
    queryClick(){
      this.param.content.where.condition = this.search
      this.listData()
    }

  },
  mounted() {
    this.listData()
  },
  created() {
    this.tablecols = this.tool.tabelCol(this.$route.name).followLeads.tablecols
  },
}
</script>

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

</style>