<template>
  <div class="edit-add-detail">
    <!-- <div class="crumbs">
        <Breadcrumb
            :breadcrumbOpt="breadcrumbOpt"
            svg-name="#icon-icon_achievements_submit"
            @breadcrumb-click="breadcrumbClick"
        />
    </div> -->
    <div class="form-content">
      <div class="company-information">
        <el-form
          ref="formInfo"
          :model="parameter"
          label-position="right"
          label-width="120px"
        >
          <div class="rows">
            <div class="rows-left">
              <div class="rows-hr"></div>
            </div>
            <div class="rows-title">
              <div class="text-overflow">基本信息</div>
            </div>
          </div>
          <el-row :gutter="24">
            <el-col :span="6">
              <el-form-item label="交易对象" prop="name">
                <span>{{ parameter.name }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="交易方式" prop="dealType">
                <span>{{ parameter.dealType }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="债权归属单位"
                prop="belongsOrgName"
              >
                <span>{{ parameter.belongsOrgName }}</span>
              </el-form-item>
            </el-col>
            <!-- <el-col :span="6">
                <el-form-item label="公司性质" prop="assetNature">
                    <span>
                        {{
                            getDictName(
                                'gqgsxz',
                                parameter.assetNature
                            )
                        }}</span
                    >
                </el-form-item>
            </el-col> -->
            <el-col :span="6" prop="dealOrg">
              <el-form-item label="交易机构">
                <span>{{ parameter.dealOrg }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="6">
              <el-form-item
                label="合同金额(万元)"
                prop="contractMoney"
              >
                <span>{{ parameter.contractMoney }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                label="年收益率(%/年)"
                prop="yearEarningsRate"
              >
                <span>{{ parameter.yearEarningsRate }}</span>
              </el-form-item>
            </el-col>

            <el-col :span="6">
              <el-form-item
                label="还本付息方式"
                prop="returnType"
              >
                                <span>
                                    {{
                                        getDictName(
                                            'hbfxfs',
                                            parameter.returnType
                                        )
                                    }}</span
                                >
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="期限" prop="dateLimit">
                <span>{{ parameter.dateLimit }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="6">
              <el-form-item label="起始日期" prop="startDate">
                <span>{{ parameter.startDate }}</span>
              </el-form-item>
            </el-col>

            <el-col :span="6" prop="endDate">
              <el-form-item label="到期日期">
                <span>{{ parameter.endDate }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="6" prop="riskMeasures">
              <el-form-item label="风控措施">
                <span>{{ parameter.riskMeasures }}</span>
              </el-form-item>
            </el-col>

            <el-col :span="6">
              <el-form-item label="债权状态" prop="loanStatus">
                                <span>
                                    {{
                                        getDictName(
                                            'zqzt',
                                            parameter.loanStatus
                                        )
                                    }}</span
                                >
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col
              :span="6"
              prop="auditMsg"
              v-if="parameter.assetAudit === '1'"
            >
              <el-form-item label="驳回理由">
                <span>{{ parameter.auditMsg }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="18">
              <el-form-item label="备注">
                <span>{{ parameter.remark }}</span>
              </el-form-item>
            </el-col>
          </el-row>
          <div class="rows">
            <div class="rows-left">
              <div class="rows-hr"></div>
            </div>
            <div class="rows-title">
              <div class="text-overflow">债权归还信息</div>
            </div>
          </div>
          <el-table
            :data="parameter.loanInterest"
            style="width: 100%"
            border
          >
            <el-table-column type="index" label="序号" width="80">
            </el-table-column>
            <el-table-column
              prop="receivableMoney"
              label="应收利息(万元)"
            >
            </el-table-column>
            <el-table-column
              prop="actualMoney"
              label="实收利息(万元)"
            >
            </el-table-column>
            <el-table-column
              prop="addUpMoney"
              label="累计收到利息(万元)"
            >
            </el-table-column>
            <el-table-column
              prop="willReturnDate"
              label="应归还日期"
            >
            </el-table-column>
            <el-table-column prop="returnDate" label="归还日期">
            </el-table-column>
            <el-table-column
              prop="isOverdue"
              show-overflow-tooltip
              min-width="120"
              align="center"
              label="是否逾期归还"
            >
              <template v-slot="{row}">
                {{ getDictName('zqzt', row.isOverdue) }}
              </template>
            </el-table-column>
            <el-table-column prop="remark" label="备注">
            </el-table-column>
          </el-table>
        </el-form>
      </div>
    </div>
    <div slot="footer" class="footer">
      <el-button
        type="primary"
        @click="handleSave"
        v-if="parameter.assetAudit === '0'"
      >审核通过
      </el-button
      >
      <el-button
        type="danger"
        @click="turnDown"
        v-if="parameter.assetAudit === '0'"
      >审核驳回
      </el-button
      >
      <el-button @click="breadcrumbClick">{{
        $t('domestic.cancel')
        }}
      </el-button>
    </div>
  </div>
</template>

<script>
import Breadcrumb from '@/components/Breadcrumb/index.vue'
import utils from '@/utils/utils.js'
import api from '@/api/BondAssets/BondAssetsEnter/RegisterInboundEnter.js'

export default {
  name: 'domesticDialog',
  components: {Breadcrumb},
  data() {
    return {
      breadcrumbOpt: [
        {breadcrumbName: '登记入库审核'},
        {breadcrumbName: '详情'}
      ],
      parameter: {}
    }
  },
  created() {
  },
  mounted() {
  },
  methods: {
    //字典翻译
    getDictName(code, value) {
      return utils.getDictName(code, value)
    },
    //面包屑点击
    breadcrumbClick() {
      this.$emit('closeComponent')
    },
    //详情
    detail(val) {
      if (val) {
        this.modifychoData(val)
      }
    },
    //获取详情
    modifychoData(val) {
      api.detailsData(val.id, (res) => {
        if (res) {
          this.parameter = res
          console.log(this.parameter)
        }
      })
    },
    // 审核
    handleSave() {
      api.processData(this.parameter.id, '2', '', (res) => {
        if (res.state) {
          this.$message.success('审核成功')
          this.$emit('closeComponent')
        }
      })
    },
    //驳回
    turnDown() {
      this.$prompt('', '驳回理由', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputPattern: /^[^\s][\s\S]*$/,
        inputErrorMessage: '请输入驳回理由'
      })
        .then(({value}) => {
          api.examine(this.parameter.id, '1', value, (res) => {
            if (res.state) {
              this.$message.success(`驳回成功`)
              this.$emit('closeComponent')
            }
          })
        })
        .catch(() => {
        })
    }
  }
}
</script>
<style lang="scss" scoped>
.edit-add-detail {
  display: flex;
  flex-direction: column;

  // .crumbs {
  // }
  .form-content {
    flex: 1;

    // margin-top: 20px;
    border-radius: 10px;
    overflow-y: scroll;

    .company-information {
      border-radius: 10px;
      padding: 10px 20px;
      background-color: white;
      margin-bottom: 20px;
    }
  }

  .form-content::-webkit-scrollbar {
    display: none;
    /* Chrome Safari */
  }

  .footer {
    height: 100px;
    background-color: white;
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
}

::v-deep .el-form-item__label {
  width: 120px;
  font-size: 14px;
  color: #828282;
  font-weight: 500;
}

::v-deep .el-form-item__content span {
  font-size: 14px;
  color: #000;
  font-weight: 500;
}

::v-deep .el-form-item {
  margin-bottom: 10px;
}

.rows {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ebebeb;
  margin-bottom: 16px;
  padding: 10px 0;

  .rows-left {
    margin-right: 10px;

    .rows-hr {
      width: 3px;
      height: 18px;
      background-color: #0e6eff;
      border-radius: 2px;
    }
  }

  .rows-title {
    .text-overflow {
      width: 100%;
      font-size: 16px;
    }
  }
}
</style>
