<template>
  <div>
    <ele-pro-table
      ref="table"
      :needPage="false"
      :columns="columns"
      :datasource="datasource"
      class="time-form"
    >
      <!-- 查看详情列 -->
      <template v-slot:contractName="{ row }">
        <el-link type="primary" :underline="false" @click="openDetail(row)">
          {{ row.contractName }}
        </el-link>
      </template>
    </ele-pro-table>
    <detail-dialog ref="contactDetailDialogRef"></detail-dialog>
  </div>
</template>
<script>
  import { reviewStatus } from '@/enum/dict';
  import { changeHistory } from '@/api/contractManage/contractChange.js';
  import detailDialog from './detailDialog1.vue';

  export default {
    components: { detailDialog },
    data() {
      return {
        datasource: [],
        columns: [
        {
            columnKey: 'index',
            label: '序号',
            type: 'index',
            width: 55,
            align: 'center',
            showOverflowTooltip: true,
            fixed: 'left'
          },
          {
            prop: 'contractName',
            label: '合同名称',
            align: 'center',
            slot: 'contractName',
            showOverflowTooltip: true,
            minWidth: 200
          },

          {
            prop: 'categoryName',
            label: '合同分类',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 140
          },
          {
            minWidth: 200,
            prop: 'changeReason',
            label: '变更原因',
            align: 'center',
            showOverflowTooltip: true
          },
          {
            minWidth: 200,
            prop: 'changeRemark',
            label: '变更描述',
            align: 'center',
            showOverflowTooltip: true
          },
          {
            minWidth: 140,
            prop: 'changeTime',
            label: '变更时间',
            align: 'center',
            showOverflowTooltip: true
          },
          {
            prop: 'dversion',
            label: '版本号',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 80
          },
          {
            prop: 'productNames',
            label: '产品名称',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 140
          },
          {
            prop: 'partaName',
            label: '甲方名称',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 150
          },
          {
            prop: 'partaLinkName',
            label: '甲方联系人',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 130
          },

          {
            prop: 'partaTel',
            label: '甲方联系电话',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 130
          },
          {
            prop: 'partbName',
            label: '乙方名称',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 130
          },
          {
            prop: 'partbLinkName',
            label: '乙方联系人',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 130
          },
          {
            prop: 'partbTel',
            label: '乙方联系电话',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 130
          },

          {
            prop: 'contractNo',
            label: '编码',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 170
          },
          {
            prop: 'contractNumber',
            label: '合同编号',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 200
          },

          {
            prop: 'enabled',
            label: '是否可用',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 140,
            formatter: (_row, _column, cellValue) => {
              return _row.enabled ? '是' : '否';
            }
          },
          {
            prop: 'contractStartDate',
            label: '签订日期',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 140
          },
          {
            prop: 'contractEndDate',
            label: '结束日期',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 140
          },
          {
            prop: 'receiptPaymentType',
            label: '收付款类型',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 130,
            formatter: (_row, _column, cellValue) => {
              return _row.receiptPaymentType == 1 ? '固定' : '分期';
            }
          },
          {
            prop: 'totalPrice',
            label: '合同总金额',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 130
          },

          {
            prop: 'status',
            label: '审核状态',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 100,
            formatter: (_row, _column, cellValue) => {
              return reviewStatus[_row.status];
            }
          },
          {
            prop: 'createUsername',
            label: '创建人',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 120
          },
          {
            prop: 'createTime',
            label: '创建时间',
            align: 'center',
            showOverflowTooltip: true,
            minWidth: 150
          },
        ]
      };
    },

    methods: {
      //查看详情
      openDetail(row) {
        this.$refs.contactDetailDialogRef.open({id:row.id});
      },
      init(id) {
        changeHistory(id).then((res) => {
          this.datasource=res
        });
      }
    }
  };
</script>
<style lang="scss" scoped></style>
