<template>
  <div class="private-lending">
    <cy-comm-table
      ref="commTable"
      :columns="columns"
      :data="tableData"
    />
  </div>
</template>

<script>
export default {
  props: {
    disabled: {
      type: Boolean,
      default: false
    },
    type: {
      type: String,
      default: ''
    },
    detailsData: {
      type: Array,
      default: () => []
    }
  },
  inject: {
    disabled: {
      form: 'disabled',
      default: false
    }
  },
  data() {
    return {
      tableData: []
    }
  },
  computed: {
    columns() {
      return [
        {
          label: '序号',
          index: true
        },
        {
          label: '文书标题',
          prop: 'caseName',
          showTooltip: true
        },
        {
          label: '案由',
          showTooltip: true,
          prop: 'caseReason'
        },
        {
          label: '案号',
          prop: 'caseNo'
        },
        {
          label: '案件金额',
          prop: 'amount',
          showTooltip: true
        },
        {
          label: '裁判结果',
          prop: 'judgeResult',
          showTooltip: true
        },
        {
          label: '裁判日期',
          prop: 'judgeDate'
        },
        {
          label: '发布日期',
          prop: 'publishDate'
        },
        {
          label: '当事人',
          prop: 'personName'
        },
        {
          label: '是否民间借贷',
          prop: 'privateLending',
          ruleRequired: this.type === 'supplier' || this.type === 'videoDue' || this.type === 'projectOwner',
          render: (h, row) => {
            return <el-select
              v-model={row.privateLending}
              disabled={this.disabled}
              placeholder='请选择民间借贷'>
              <el-option label='是' value={1}></el-option>
              <el-option label='否' value={0}></el-option>
            </el-select>
          }
        },
        {
          label: '民间借贷（调整）',
          prop: 'inDate',
          show: this.type === 'videoDue',
          render: (h, row) => {
            return <el-select
              disabled={this.disabled}
              v-model={row.videoDueDiligencePrivateLending}
              placeholder='请选择民间借贷'>
              <el-option label='是' value={1}></el-option>
              <el-option label='否' value={0}></el-option>
            </el-select>
          }
        }
      ]
    }
  },
  watch: {
    detailsData: {
      handler(newV) {
        this.tableData = JSON.parse(JSON.stringify(newV))
      },
      deep: true
    }
  }
}
</script>

<style lang="scss" scoped>
.private-lending {

}
</style>
