<template>
  <section class="risk-detail-section">
    <div class="section-card">
      <div class="block">
        <div class="block-header">
          <div>
            <div class="block-title">涉险交易明细</div>
            <div class="block-subtitle">展示涉险交易的关键字段与风险金额</div>
          </div>
          <el-button size="mini" type="text">导出</el-button>
        </div>

        <el-table :data="sectionData.transactionList || []" class="detail-table">
          <el-table-column type="index" label="序号" width="60" />
          <el-table-column prop="tradeDate" label="交易日期" min-width="120" />
          <el-table-column prop="counterparty" label="对手方" min-width="120" />
          <el-table-column prop="direction" label="方向" min-width="100" />
          <el-table-column prop="accountNo" label="账号" min-width="180" />
          <el-table-column prop="summary" label="摘要" min-width="180" />
          <el-table-column prop="amount" label="金额" min-width="120" align="right">
            <template slot-scope="scope">
              <span :class="scope.row.amount >= 0 ? 'amount-in' : 'amount-out'">
                {{ formatAmount(scope.row.amount) }}
              </span>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="100" align="right">
            <template slot-scope="scope">
              <el-button type="text" size="mini">{{ scope.row.actionLabel || "查看详情" }}</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>

      <div class="block">
        <div class="block-header">
          <div>
            <div class="block-title">异常账户人员信息</div>
            <div class="block-subtitle">展示异常账户关联人员与处理状态</div>
          </div>
          <el-button size="mini" type="text">导出</el-button>
        </div>

        <el-table :data="sectionData.abnormalAccountList || []" class="detail-table">
          <el-table-column prop="accountNo" label="账户号" min-width="160" />
          <el-table-column prop="accountName" label="账户人姓名" min-width="120" />
          <el-table-column prop="bankName" label="开户银行" min-width="180" />
          <el-table-column prop="lastTradeDate" label="异常发生时间" min-width="140" />
          <el-table-column prop="handler" label="状态" min-width="100" />
          <el-table-column label="操作" width="100" align="right">
            <template slot-scope="scope">
              <el-button type="text" size="mini">{{ scope.row.actionLabel || "查看详情" }}</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </section>
</template>

<script>
export default {
  name: "RiskDetailSection",
  props: {
    sectionData: {
      type: Object,
      default: () => ({}),
    },
  },
  methods: {
    formatAmount(value) {
      const amount = Number(value || 0);
      const absValue = Math.abs(amount).toLocaleString("zh-CN", {
        minimumFractionDigits: 2,
        maximumFractionDigits: 2,
      });
      return `${amount >= 0 ? "+" : "-"}${absValue}`;
    },
  },
};
</script>

<style lang="scss" scoped>
.risk-detail-section {
  margin-bottom: 16px;
}

.section-card {
  padding: 20px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.block + .block {
  margin-top: 24px;
}

.block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.block-title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.block-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: #94a3b8;
}

.detail-table {
  border-radius: 12px;
  overflow: hidden;
}

.detail-table /deep/ th {
  background: #f8fafc;
  color: #64748b;
}

.amount-in {
  color: #16a34a;
  font-weight: 600;
}

.amount-out {
  color: #ef4444;
  font-weight: 600;
}
</style>
