<template>
<div class="h100">
  <common-layout

    :form-attrs="{
       spanAttrs: {
         span:5
       }
     }"
    :table-attrs="{
       'has-operation':true,

     }"
    ref="layoutRef"
    :table-header="safeReportHomeTableHeader"
    :filter-form="safeReportHomeFilterForm()"
    :get-table-list="getTableList"
  >
    <template #operation="{data}">
      <el-button type="info" @click="exportE(data)">导出</el-button>
    </template>
  </common-layout>
</div>
</template>

<script>
import CommonLayout from "@/components/CommonLayout.vue";
import {safeReportHomeFilterForm} from "@/data/all-forms";
import {ref} from "vue";
import {safeReportHomeTableHeader} from "@/data/all-table-header";
import {getSafeCheckHomeT} from "@/service/zsk/safe-check";
import {getSafeReportTableData} from "@/service/zsk/safe-report";
import {baseUrl} from "@/service/config";
import {useRootStore} from "@/stores/useStore";

export default {
  name: "SafeReport",
  components: {CommonLayout},
  setup() {
    function getTableList(){

      getSafeReportTableData({
        PAGEINDEX:layoutRef.value.pageIndex,
        PAGESIZE:layoutRef.value.pageSize,
        MONTH_TIME:layoutRef.value.form.MONTH_TIME,
        UNIT_CODE:layoutRef.value.form.UNIT_CODE,
      }).then(res => {
        layoutRef.value.getResData(res.msg[0].Rows||[],res.msg[0].TotalRowCount)
      })
    }
    function exportE(it) {
      window.open(baseUrl +`/ptjkInterface/exportSafeTaskTemplateWord?appkey=${useRootStore().userInfo.ptjk_userkeycode}&UUID=${it.UUID}`,'_blank')
    }
    const layoutRef = ref(null)
    return {
      safeReportHomeFilterForm,
      safeReportHomeTableHeader,
      layoutRef,
      getTableList,
      exportE
    }
  }
}
</script>

<style scoped lang="scss">

</style>
