<template>
  <el-table v-loading="loading" :data="analysisData" border width="100%">
    <el-table-column label="#" type="index" align="center"/>
    <el-table-column label="分析时间">
      <template #default="scope">
        {{scope.row.analyseTime}}
      </template>
    </el-table-column>
    <el-table-column label="操作" width="150" align="center">
      <template #default="scope">
        <el-button type="primary" link icon="edit" @click="handleShowDetail(scope.row)">查看</el-button>
      </template>
    </el-table-column>
  </el-table>
  <pagination
      v-show="total>0"
      :total="total"
      v-model:page="page.pageNum"
      v-model:limit="page.pageSize"
      @pagination="getHistoryList"
  />

  <el-dialog :title="'分析详情'" v-model="visible" width="800" append-to-body>
    <risk-detail :rows="detailRow" v-if="visible" />
  </el-dialog>
</template>
<script setup lang="ts">
import {onMounted} from "vue";
import {listAnalysis} from "@/api/risk/r2"
const props = defineProps(['rows'])
import riskDetail from "./riskDetail.vue"
const analysisData = ref([])
const visible = ref(false)
const loading = ref(false)
const total = ref(0)
const detailRow = ref({})
const page = ref({
  pageNum: 1,
  pageSize: 10
})
onMounted(()=>{
  getHistoryList()
})

function handleShowDetail(row){
  visible.value = true
  detailRow.value = row
}

async function getHistoryList(){
  loading.value = true
  const res = await listAnalysis({riskId: props.rows.riskId,...page.value})
  analysisData.value = res.rows
  loading.value = false
  total.value = res.total
}
</script>
<style scoped lang="scss">
</style>
