<template>
  <el-dialog title="供应商信息 " :visible.sync="isShow" v-loading="loading" :close-on-click-modal="false" width="700px" z-index="10" @close="handleCancel">
    <el-table :data="tableList" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)" @row-click="handleRowClick">
      <el-table-column width="60px">
        <template slot-scope="scope">
          <el-radio v-model="selectId" :label="scope.row.id">{{''}}</el-radio>
        </template>
      </el-table-column>
      <el-table-column label="序号" type="index" />
      <el-table-column label="公司名称" prop="name" />
      <el-table-column label="银行名称" prop="name" />
      <el-table-column label="银行账号" prop="name" />
      <el-table-column label="联系人" prop="name" />
      <el-table-column label="联系电话" prop="percent" />
    </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>
import { configList } from '@/api/common'
export default {
  name: '',
  props: {
    id: [String, Number],
    isOpen: Boolean,
    disabled: Boolean,
  },
  watch: {
    isOpen: {
      handler(val) {
        this.isShow = val
        if (val) {
          this.handleInIt()
        }
      },
      deep: true,
      immediate: true
    }
  },
  data() {
    return {
      selectRow: null,
      loading: false,
      isShow: false,
      selectId: null,
      tableList: [
        { id: 1, name: '规则1', percent: '2:8' },
        { id: 2, name: '规则2', percent: '3:4:3' },
        { id: 3, name: '无规则', percent: '-' },
      ]
    }
  },
  methods: {
    handleInIt() {
      this.handleGetList().then(() => {
        if (this.id) {
          this.selectId = this.id
        } else {
          this.selectId = 3
        }
      })
    },
    handleRowClick(row) {
      this.selectId = row.id
      this.selectRow = row
    },
    handleCancel() {
      this.$emit('onCancel')
    },
    handleSave() {
      this.$emit('onConfirm', this.selectRow)
    },
    handleGetList() {
      this.loading = true
      return new Promise((resolve) => {
        // setTimeout(() => {
        // }, 1000);
        this.loading = false
        resolve()
      })
    },
  }
}
</script>

<style lang="less" scoped>
</style>