<script setup lang="ts">
import { ref, unref } from "vue";
import { PageSearch, usePageSearch } from "/@/components/PageSearch";
import searchConfig from "./config/search.config";
import contentConfig from "./config/content.config";
import { PageContent } from "/@/components/PageContent";
import type { PageContentInstance } from "/@/components/PageContent";
import addModel from "./cpns/addModel.vue";
const actionModalRef = ref<InstanceType<typeof addModel>>(null);

const pageContentRef = ref<PageContentInstance | null>(null);
const pageName = "setTheme";

const { handleResetClick, handleSearchClick } = usePageSearch();
// function handleCreate() {
//   basicFormRef.value.validate(isValid => {
//     if (!isValid) return;

//     // handleConfrim("create", {});
//   });
// }
function Create() {
  pageContentRef.value.getPageData({ id: "" });
}
function handleCreateData() {
  // console.log(actionModalRef.value);
  // console.log(actionModalRef);
  actionModalRef.value.onShow("主题设置", "create", "");
  // actionModalRef.value.confirmLoading = false;
  // actionModalRef.value.type = "create";
  // actionModalRef.value.dialogVisible = true;
}
function handleData(id, type) {
  actionModalRef.value.onShow("主题设置", type, id);
}
</script>

<template>
  <!-- <PageAuth :pageName="pageName"> -->
  <PageSearch
    :form-config="searchConfig"
    @search-btn-click="handleSearchClick"
    @reset-btn-click="handleResetClick"
  />
  <PageContent
    ref="pageContentRef"
    :content-config="contentConfig"
    @create-btn-click="handleCreateData"
    @preview-btn-click="({ id }) => handleData(id, 'preview')"
    @update-btn-click="({ id }) => handleData(id, 'update')"
  />
  <addModel ref="actionModalRef" @submitOk="Create" />

  <!-- </PageAuth> -->
</template>
