<template>
  <div v-loading="isLoading" class="acceptance-sign">

    <!-- 电子合同信息 -->
    <cy-info-title> 电子合同信息 </cy-info-title>
    <table border class="view-table" cellspacing="0">
      <tr>
        <th rowspan="100" style="width: 150px;">{{ electronicSignaturePersonal.name }}</th>
        <td style="width: 150px;">认证链接</td>
        <td>
          <div style="display: flex; flex-direction: row; justify-content: space-between;">
            <span>{{ electronicSignaturePersonal.shortAuthUrl }}</span>
          </div>
        </td>
        <td style="width: 250px;">
          认证状态：{{ electronicSignaturePersonal.authStatus ? '已认证' : '未认证' }}
        </td>
      </tr>
      <tr>
        <td>签署链接</td>
        <td colspan="2">
          <div style="display: flex; flex-direction: row; justify-content: space-between;">
            <span>{{ shortContractLink }}</span>
          </div>
        </td>
      </tr>
      <tr v-for="item in acceptanceSignConfirmationElectronicInfoHistories" :key="item.id">
        <td colspan="2">{{ item.contractName }}</td>
        <td>
          签署状态：{{ item.signStatus ? '已签署' : '未签署' }}
        </td>
      </tr>
    </table>

    <!-- 签署结论 -->
    <cy-info-title style="margin: 10px 0 0px;"> 签署结论 </cy-info-title>
    <el-form
      ref="ruleFormRef"
      :model="ruleForm"
      label-position="top"
      label-width="150px"
      class="rule-form-orange"
      :style="formStyle"
    >
      <el-form-item label="签署结论" prop="signConclusion" style="width: 100%;">
        <el-radio-group v-model="ruleForm.signConclusion">
          <el-radio :label="1" disabled>完成</el-radio>
          <el-radio :label="0" disabled>终止</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="说明" style="width: 100%;" prop="remark">
        <el-input v-model="ruleForm.remark" type="textarea" :rows="3" placeholder="请输入说明" disabled />
      </el-form-item>
    </el-form>

  </div>
</template>

<script>
export default {
  name: 'AcceptanceSign',
  props: {
    'formStyle': {
      type: Object,
      default: () => {}
    },
    detailsInfo: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      ruleForm: {
        signConclusion: '',
        remark: ''
      },
      electronicSignaturePersonal: '',
      shortContractLink: '',
      acceptanceSignConfirmationElectronicInfoHistories: [],
      isLoading: false

    }
  },
  watch: {
    detailsInfo: {
      handler(newV) {
        if (Object.keys(newV).length) {
          const {
            electronicSignaturePersonal,
            shortContractLink,
            acceptanceSignConfirmationElectronicInfoHistories,
            signConclusion,
            remark
          } = JSON.parse(JSON.stringify(newV))
          this.ruleForm = { signConclusion, remark }

          this.electronicSignaturePersonal = electronicSignaturePersonal
          this.shortContractLink = shortContractLink
          this.acceptanceSignConfirmationElectronicInfoHistories = acceptanceSignConfirmationElectronicInfoHistories
        }
      },
      immediate: true,
      deep: true
    }
  }
}
</script>
    <style lang="scss" scoped>
    .acceptance-sign {
      padding: 10px 20px;

      .view-table {
        width: 100%;
        border-color: rgba(228, 228, 228, .2);
        margin-bottom: 20px;
        table-layout: fixed;
        tr {
          width: 100%;
          td, th {
            border-width: 1px;
            border-color: rgba(228, 228, 228, .2);
            height: 40px;
            padding-left: 10px;
            background-color: #ffffff;
            word-break: break-all;
          }
          th {
            background-color: #f5f6f6;
            font-weight: normal;
          }
        }
      }
      .el-form {
          padding: 10px 20px;
      }
      .statistics {
          color: #FF0000;
          margin-left: 20px;
          font-size: 14px;
      }
    }
    </style>
