
<template>
  <div>
    <div style="margin-top: -10px">
      <add class="inline-16" :data="data" @addSuccess="onSuccess" ></add>
      <el-input
          placeholder="请输入搜索内容"
          suffix-icon="el-icon-search"
          v-model="search"
          style="width:200px"
          size="small"
          class="input-with-select inline-16"
          @keyup.native.enter="queryClick"
          @clear="clearData"
          clearable>
      </el-input>
    </div>
    <div style="margin-top: 20px">
      <tableLayout :layout="tablecols" :data="list" :opwidth="200" :custom="true"  :height="tableHieght" >
        <template v-slot:customcol="scope">
          <p >{{scope.column.data[scope.column.columnname]}}</p>
        </template>
        <template v-slot:opreation="scope">
<!--          <edit class="inline-16" v-if="tool.checkAuth($route.name,'update')" :data="scope.data" @updateSuccess="onSuccess"></edit>
          <to_del class="inline-16" :data="scope.data" @toDelSuccess="onSuccess"></to_del>-->
          <!--          <toVoid v-if="tool.checkAuth($route.name,'toVoid')" :data="scope.data" @toVoidSuccess="onSuccess"></toVoid>-->
        </template>
      </tableLayout>
    </div>
    <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"
          layout="total, prev, pager, next, jumper"
          :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import add from './add'
import edit from "@/HDrpManagement/projectChange/modules/modules/andEnterprise/components/edit";
import to_del from "@/HDrpManagement/projectChange/modules/modules/andEnterprise/components/toDel";
export default {
  props:["data"],
  components:{add},
  data () {
    return {
      tableHieght:"600px",
      tablecols:[],
      list:[],
      total:0,
      currentPage:0,
      search:'',
      options:[],
      productList:'',
      params:{
        "id": 20221021145702,
        "content": {
          "sa_projectid": 2,
          "pageNumber": 1,
          "pageSize": 20,
          "where": {
            "condition": ""
          }
        },
      }
    }
  },
  provide () {
    return {
      productList:() => this.productList
    }
  },
  methods:{
    /*list (vm) {
      vm.content.sa_projectid = this.$route.query.id
    },*/

    async listData(){
      this.params.content.sa_projectid = this.data.sa_projectid
      const res = await this.$api.requested(this.params)
      console.log(res,'____________________________')
      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()
    },
    onSuccess(){
      this.listData()
    },
    clearData(){
      console.log("执行")
      this.search = ""
      this.params.content.where.condition = this.search
      this.listData()
    },
    queryClick(){
      this.params.content.where.condition = this.search
      this.listData()
    }
  },
  created() {
    /*this.getProductList()*/
    this.tablecols = this.tool.tabelCol(this.$route.name).projectSetTable.tablecols
  },
  mounted () {
    this.listData()
  }
}

</script>
<style scoped>
/* /deep/.el-table__cell .cell {
  display: flex;
  justify-content: s;
} */
</style>