<!-- 付款计划列表 -->
<template>
  <el-dialog title="付款计划列表" :visible.sync="isShow" :close-on-click-modal="false" class="drawer-box" width="700px" @close="handleCancel" append-to-body>
    <el-table ref="table" :data="tableData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55">
      </el-table-column>
      <el-table-column prop="name" label="姓名" width="120">
      </el-table-column>
      <el-table-column prop="address" label="地址" show-overflow-tooltip>
      </el-table-column>
    </el-table>
    <div slot="footer" class="dialog-footer">
      <el-button @click="handleCancel" size="small">取消</el-button>
      <el-button type="primary" size="small" @click="handleSave">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: '',
  props: {
    isOpen: Boolean,
    propSelectArr: Array,
  },
  watch: {
    isOpen: {
      handler(val) {
        this.isShow = val
        if (val) {
          this.handleInit()
        }
      },
      deep: true,
      immediate: true
    }
  },
  data() {
    return {
      isShow: false,
      selectArr: [],
      tableData: [{
        id: 1,
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        id: 2,
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        id: 3,
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }
      ],
      multipleSelection: []
    }
  },


  methods: {
    handleInit() {
      this.$nextTick(() => {
        if (this.propSelectArr.length) {
          this.$refs.table.toggleRowSelection(this.propSelectArr, true)
        } else {
          this.$refs.table.clearSelection()
        }
      })
    },
    handleSave() {
      this.$emit('onConfirm', this.selectArr)
    },
    handleCancel() {
      this.$emit('onCancel')
    },
    handleSelectionChange(val) {
      console.log('selectArr', val);
      this.selectArr = val;
    }
  }
}

</script>
<style lang='scss' scoped>
</style>