<template>
  <div class="data-dictionary h100">
    <common-layout  ref="layoutRef" :table-attrs="{
     'has-operation':true
   }" :form-attrs="{
     'span-attrs':{
       span:5
     }
   }" :table-header="labelRuleHomeTableHeader" :get-table-list="getTableTata" :filter-form="labelRuleHomeFilterForm">
      <template #operation="{data}">
        <el-button type="info" @click="$emit('changeOperation','edit',data)" v-if="data.NUM >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 { labelRuleHomeFilterForm} from "@/data/all-forms";
import {
 labelRuleHomeTableHeader,

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


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

    }

    return {
      labelRuleHomeFilterForm,
      labelRuleHomeTableHeader,
      getTableTata,
      layoutRef
    }
  }
}
</script>

<style scoped lang="scss">

</style>
