<script setup lang="ts">
import { ref } from "vue";
import { PageSearch, usePageSearch } from "/@/components/PageSearch";
import { usePermission } from "/@/hooks/core/usePermission";
import { PageContent } from "/@/components/PageContent";
import searchConfig from "../company/config/search.config";
import contentConfig from "../company/config/content.config";
import ShareModal from "./components/share-modal.vue";

const pageName = "dataShare";

defineOptions({
  name: "dataShare"
});

const { pageContentRef, handleResetClick, handleSearchClick } = usePageSearch();

const shareModalRef = ref<InstanceType<typeof ShareModal>>(null);

const { permissions, hasPermissionWithCode } = usePermission(pageName);
</script>

<template>
  <div class="main role">
    <PagePower :is-show="hasPermissionWithCode('001')">
      <div w-full>
        <PageSearch
          :form-config="searchConfig"
          @search-btn-click="handleSearchClick"
          @reset-btn-click="handleResetClick"
        />
        <PageContent
          ref="pageContentRef"
          :powers="permissions"
          :content-config="contentConfig"
          @create-btn-click="() => shareModalRef.onDisplay()"
          @preview-btn-click="({ id }) => shareModalRef.onDisplay(id, true)"
          @update-btn-click="({ id }) => shareModalRef.onDisplay(id)"
        />
      </div>
    </PagePower>

    <ShareModal ref="shareModalRef" @reload="() => handleResetClick()" />
  </div>
</template>

<style scoped lang="scss">
:deep(.el-dropdown-menu__item i) {
  margin: 0;
}
</style>
