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

     :table-attrs="{
       'has-operation':true
     }"
     ref="layoutRef"
     :form-attrs="{
     span:5
     }"
     :filter-form="labelRecordHomeFilterForm()"
     :table-header="labelRecordTableHeader"
     :get-table-list="getTableList"


   >
   <template #operation="{data}">
     <el-button type="info" @click="operationDialog(data)">查看详情</el-button>
   </template>
   </common-layout>
   <template v-if="isDetailDialogShow">
     <label-record-detail-dialog :current-op-obj="currentOpObj" v-model:dialog-visible="isDetailDialogShow"/>
   </template>
 </div>
</template>

<script>
import CommonLayout from "@/components/CommonLayout.vue";
import {labelRecordHomeFilterForm} from "@/data/all-forms";
import {labelRecordTableHeader} from "@/data/all-table-header";
import {ref} from "vue";
import LabelRecordDetailDialog from "@/view/other/c-views/data-handle/data-label/label-record/LabelRecordDetailDialog.vue";
import {getLabelRecordHomeTableData} from "@/service/label-record";

export default {
  name: "LabelRecord",
  components: {LabelRecordDetailDialog, CommonLayout},
  setup() {
    const isDetailDialogShow = ref(false)
    const layoutRef = ref(null)
    const currentOpObj = ref(null)
    function operationDialog(item) {
      isDetailDialogShow.value = true
      currentOpObj.value = item||{}
    }
    function getTableList() {
      getLabelRecordHomeTableData({
        pageIndex:layoutRef.value.pageIndex,
        pageSize:layoutRef.value.pageSize,
        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 {
      labelRecordHomeFilterForm,
      labelRecordTableHeader,
      getTableList,
      layoutRef,
      isDetailDialogShow,
      operationDialog,
      currentOpObj
    }
  }
}
</script>

<style scoped lang="scss">

</style>
