<template>
  <div>
    <p-table-edit :ref="refname" :columns="columns" :data-source="data">
      <div :slot="tableColSlots[0]" slot-scope="text, record">
        <slot :name="tableColSlots[0]" :record="record"> </slot>
      </div>
    </p-table-edit>
  </div>
</template>

<script>
export default {
  name: 'TableEdit',
  props: {
    columns: {
      type: Array,
      default: () => []
    },
    data: {
      type: Array,
      default: () => {}
    },
    refname: {
      type: String,
      default: ''
    }
  },
  watch: {
    columns: {
      handler(columns) {
        if (!Array.isArray(columns)) return
        this.tableColSlots = columns.filter(t => t.scopedSlots).map(t => t.scopedSlots.customRender)
      },
      immediate: true
    }
  },
  mounted() {
  },
  data() {
    return {
      tableColSlots: [],
      list: [],
      key: 'tab1',
      noTitleKey: 'app'
    }
  },
  methods: {
    createrow() {
      this.$refs[this.refname].createRow()
    },
    getdata(refname) {
      // this.$refs.tableedit.createRow()
      this.$emit('setdata', this.data, refname)
    }
  }
}
</script>

<style></style>
