
<template>
  <div>
    <div style="display:flex;align-items:center">
      <el-input
          placeholder="请输入搜索内容"
          suffix-icon="el-icon-search"
          v-model="params.content.where.condition"
          style="width:200px"
          size="mini"
          class="input-with-select inline-16"
          @keyup.native.enter="listData(params.content.pageNumber=1)"
          @clear="clearData"
          clearable>
      </el-input>
      <slot name="addBank"></slot>
    </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>{{scope.column.data[scope.column.columnname]}}</p>
          <p v-if="!scope.column.data[scope.column.columnname] && scope.column.data[scope.column.columnname] !== 0 && scope.column.columnname != 'operation'&& scope.column.columnname != 'reason'">--</p>
        </template>
        <template v-slot:opreation="scope">
          <slot name="editBank" :data="scope.data"></slot>
          <slot name="delBank" :data="scope.data"></slot>
        </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:"calc(100vh - 380px)",
      tablecols:[],
      list:[],
      total:0,
      params:{
        "id": 20221022165803,
        "version":1,
        "content": {
            "pageNumber":1,
            "pageSize":20,
            "where":{
              "condition":''
            }
        }
      },
      options:[
      ],
      productList:'',
      currentProduct:{}
    }
  },
  methods:{
    async save (data) {
      let res = await this.$api.requested({
        "id": "20230105111003",
        "version":1,
        "content": {
            "sa_aftersalesmagid":this.data.sys_enterpriseid,
            "iteminfos":[
                {
                    "sa_aftersalesmag_itemsid":data.sa_aftersalesmag_itemsid,
                    "sa_orderitemsid":data.sa_orderitemsid,
                    "itemid": data.itemid,
                    "reason":data.reason,
                    "qty":data.qty,
                    "price":data.price
                }
            ]

        }
      })
      this.tool.showMessage(res,() => {
        this.$emit('onSuccess')
        this.listData()
        this.currentProduct = ''
      })
    },
    async listData(){
      this.params.content.sys_enterpriseid = this.data.sys_enterpriseid
      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.listData()
    },
    queryClick(){
      this.listData()
    }
  },
  created() {
    this.listData()
    this.tablecols = this.tool.tabelCol(this.$route.name).bankInfoTable.tablecols
  }
}

</script>
<style scoped>

</style>