<template>
  <div class="data-dictionary h100">
    <common-layout  ref="layoutRef" :table-attrs="{
     'has-operation':true
   }" :form-attrs="{
     'span-attrs':{
       span:5
     }
   }" :table-header="safeRuleHomeTableHeader" :get-table-list="getTableTata" :filter-form="clearRuleHomeFilterForm()">
      <template #operation="{data}">
        <el-button type="info" @click="$emit('changeOperation','edit',data)" v-if="data.RULES_SUM > 0">修改规则</el-button>
        <el-button type="info" @click="$emit('changeOperation','edit',data)" v-else>配置规则</el-button>

      </template>
    </common-layout>
  </div>
</template>

<script>
import CommonLayout from "@/components/CommonLayout.vue";
import {clearRuleHomeFilterForm, dataDictionaryHomeFilterForm} from "@/data/all-forms";
import {
  clearRuleHomeTableHeader, safeRuleHomeTableHeader,

} from "@/data/all-table-header";
import {ref} from "vue";
import {getSafeRuleHomeTableData} from "@/service/zsk/safe-rule";
import {useActiveGetTableData} from "@/unit/use-method/usePagination";

export default {
  name: "SafeRuleHome",
  components: {CommonLayout},
  setup() {
    useActiveGetTableData(getTableTata)
    const layoutRef = ref(null)
    function getTableTata() {
      getSafeRuleHomeTableData({
        pageIndex:layoutRef.value.pageIndex,
        pageSize:layoutRef.value.pageSize,
        CONFIG_STATES:layoutRef.value.form.taskStatus,
        CATALOG_NAME:layoutRef.value.form.catalogName,
        UNIT_CODE:layoutRef.value.form.unitCode,
      }).then(res => {
        layoutRef.value.getResData(res.msg[0].Rows,res.msg[0].TotalRowCount)
      })

    }
    return {
      clearRuleHomeFilterForm,
      safeRuleHomeTableHeader,
      getTableTata,
      layoutRef
    }
  }
}
</script>

<style scoped lang="scss">

</style>
