<template>
<div class="h100">
  <common-layout
    ref="layoutRef"
  :get-table-list="getTableList"
  :form-attrs="{
    spanAttrs: {
      span:4
    }
  }"
  :table-attrs="{
    'has-operation':true
  }"
  :table-header="clearRecordHomeTableHeader"
  :filter-form="clearRecordHomeFilterForm"

  >
    <template #TASK_STATUS="{data}">
      {{data['TASK_STATUS'] === '1'?'成功':(data['TASK_STATUS'] === '2'?'失败':'')}}
    </template>
    <template #operation="{data}">
      <el-button  type="info" :disabled="+data.CLEANING_NUM === 0" @click="openModel(data)">查看详情</el-button>
    </template>
  </common-layout>
  <template v-if="isClearRecordDialogIsShow">
    <clear-record-dialog :current-dialog-op-obj="currentOpObj" v-model:dialog-visible="isClearRecordDialogIsShow"/>
  </template>
</div>
</template>

<script>
import CommonLayout from "@/components/CommonLayout.vue";
import {ref} from 'vue'
import {clearRecordHomeFilterForm} from "@/data/all-forms";
import {clearRecordHomeTableHeader} from "@/data/all-table-header";
import {getClearRecordHomeTableData} from "@/service/clear-record";
import ClearRecordDialog from "@/view/other/c-views/data-handle/data-clear/clear-record/ClearRecordDialog.vue";
import {useDetailOrEdit} from "@/unit/use-method/usePagination";
export default {
  name: "ClearRecordHome",
  components: {ClearRecordDialog, CommonLayout},
  setup() {
    const isClearRecordDialogIsShow = ref(false)
    const layoutRef = ref(null)
    const {changeOperation,operationType,currentOpObj} = useDetailOrEdit(getTableList)
    function openModel(data) {
      isClearRecordDialogIsShow.value = true
      changeOperation('detail',data)
    }
    function getTableList(){
      getClearRecordHomeTableData({
        pageIndex:layoutRef.value.pageIndex,
        pageSize:layoutRef.value.pageSize,
        catalogName:layoutRef.value.form.catalogName || '',
        taskStatus:layoutRef.value.form.taskStatus || '',
        startDate:layoutRef.value.form.startDate || '',
        endDate:layoutRef.value.form.endDate || '',
      }).then(res => {
        layoutRef.value.getResData(res.msg[0].Rows||[],res.msg[0].TotalRowCount)
      })
    }
    return {
      layoutRef,
      getTableList,
      clearRecordHomeFilterForm,
      clearRecordHomeTableHeader,
      changeOperation,operationType,currentOpObj,
      isClearRecordDialogIsShow,
      openModel
    }
  }
}
</script>

<style scoped lang="scss">

</style>
