<script setup lang="ts">
import { ref , shallowRef, watch} from "vue";
import searchConfig from "./config/search.config";
import contentConfig from "./config/content.config";

import { PageContentInstance } from "/@/components/PageContent";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
import { usePageSearch, type PageHooks } from "/@/hooks/page";
import { isBeyondTime } from "/@/views/time/_utils";
import { usePermission } from "/@/hooks/core";
import { useUserStore } from "/@/store/modules/user";
import UpdateModal from "./components/update-modal.vue";

const pageName = "updateStat";
const { hasPermissionWithCode } = usePermission(pageName);
const pageContentRef = ref<PageContentInstance | null>(null);
const updateModalRef = ref<InstanceType<typeof UpdateModal> | null>(null);
const loading = shallowRef(false);

const hooks: PageHooks = {
  pageSearchHook: () =>  usePageSearch(undefined, undefined, searchConfig)
};

function handleEdit(row) { 
  updateModalRef.value?.onDisplay(row);
}
</script>

<template>
  <page-auth :page-name="pageName">
    <page-container
      :hooks="hooks"
      :page-name="pageName"
      :get-content-ref="ref => (pageContentRef = ref)"
      :content-config="contentConfig"
    >
      <!-- :search-config="searchConfig" -->
      <template #content_action="row">
        <el-tooltip content="编辑" v-if="hasPermissionWithCode('4')">
          <el-button type="text" :icon="useRenderIcon('edit')" @click="handleEdit(row)" />
        </el-tooltip>
      </template>
    </page-container>
    <update-modal ref="updateModalRef" @refresh="pageContentRef.onSearch()" />
  </page-auth>
</template>
