<template>
  <el-table v-loading="loading" :data="hsTimeData" border style="width: 100%">
    <el-table-column prop="hlScoreId" label="ID" width="80"/>
    <el-table-column prop="hlDate" label="评分时间" />
    <el-table-column prop="hlScore" label="健康度得分" />
    <el-table-column label="操作" width="120">
      <template #default="scope">
        <el-button type="primary" link icon="Document" @click="handleDetail(scope.row)">明细</el-button>
      </template>
    </el-table-column>
  </el-table>
  <pagination
      v-show="total>0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getHlList"
  />

  <el-dialog v-model="visible" :title="timeTitle" width="1200">
    <time-detail :rowData="rowData" v-if="visible"/>
  </el-dialog>

</template>
<script setup lang="ts">
import {hsTimeList} from "@/api/hl/hs"
import {onMounted, reactive} from "vue";
import timeDetail from "./widget/timeDetail.vue"
const {proxy} = getCurrentInstance()
const props = defineProps(['modelId'])
const hsTimeData = ref([])
const total = ref(0)
const loading = ref(false)
const timeTitle=ref('')
const visible=ref(false)
const rowData = ref({})
const queryParams = reactive({
  pageNum:1,
  pageSize:10,
  modelId:props.modelId
})

onMounted(()=>{
  getHlList()
})

function handleDetail(row){
  timeTitle.value = row.hlDate + "明细"
  visible.value = true
  rowData.value = row
}

async function getHlList(){
  loading.value = true
  const res =  await hsTimeList(queryParams)
  hsTimeData.value = res.rows
  total.value = res.total
  loading.value = false
}

</script>
<style scoped lang="scss">
</style>
